Postscript backend produces different file permission than png backend?

On Linux:

import pylab as p
p.plot( [1,2,3] )
p.savefig( 'test.ps' )
p.savefig( 'test.png' )

ls -l test.*
-rw-r--r-- 1 --- ----- 17236 Apr 13 10:32 test.png
-rw------- 1 --- ----- 8640 Apr 13 10:32 test.ps

This is with a umask of 022. It looks to me like this is caused by the ps backend creating a temp file and then moving it to the requested file name. The permissions in the /tmp directory are generally different than a normal file system.

Any thoughts on whether this is bug or not? It seems to me that using a temp file is an implementation detail and calling savefig should always create files w/ the user's permission settings.

I'm not sure how to "fix" this - the normal copy command preserves the permissions. I guess the temp file could be opened and the data read and then copied to the requested file.

Ted

Drain, Theodore R (343P) wrote:

On Linux:

import pylab as p
p.plot( [1,2,3] )
p.savefig( 'test.ps' )
p.savefig( 'test.png' )

ls -l test.*
-rw-r--r-- 1 --- ----- 17236 Apr 13 10:32 test.png
-rw------- 1 --- ----- 8640 Apr 13 10:32 test.ps

This is with a umask of 022. It looks to me like this is caused by
the
ps backend creating a temp file and then moving it to the requested file
name. The permissions in the /tmp directory are generally different than
a normal file system.

Any thoughts on whether this is bug or not? It seems to me that using
a temp file is an implementation detail and calling savefig should
always create files w/ the user's permission settings.

Yes, I think it is a bug.

I'm not sure how to "fix" this - the normal copy command preserves
the permissions. I guess the temp file could be opened and the data
read and then copied to the requested file.

An alternative, avoiding the copy operation, is to replace

shutil.move(tmpfile, outfile)

with

open(outfile, 'w')
mode = os.stat(outfile).st_mode
shutil.move(tmpfile, outfile)
os.chmod(outfile, mode)

Eric

ยทยทยท

Ted
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options