Re: "Cloning" file attributes and permissions

2007-04-13 Thread Kevin Kelley
This is what I (just now) put together as an example: from os import stat,mknod,chown def match_perms(org_fname,new_fname): # Get information on old file st = stat(org_fname) st_mode = st.st_mode st_uid = st.st_uid st_gid = st.st_gid # Create the new file mknod(new_fname,st

Re: "Cloning" file attributes and permissions

2007-04-13 Thread Kevin Kelley
If you know what the permissions are going to be then you can use umask to set the default file creation permissions to match. Then any files created in that directory will have the correct permissions. I think the "pythonic" way to solve this problem would be to code up your own module which han

Re: "Cloning" file attributes and permissions

2007-04-12 Thread Paulo da Silva
[EMAIL PROTECTED] escreveu: > On Apr 12, 5:19 pm, [EMAIL PROTECTED] wrote: >> On Apr 12, 4:09 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote: >> ... > > After poking around a bit I also discovered the > shutil module. It looks like you can use > shutil.copy2. More Pythonic, yes? > I have seen t

Re: "Cloning" file attributes and permissions

2007-04-12 Thread attn . steven . kuo
On Apr 12, 5:19 pm, [EMAIL PROTECTED] wrote: > On Apr 12, 4:09 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote: > (snipped) > > > import subprocess > retcode = subprocess.call([ "/bin/cp", "-p", oldfile, newfile ]) > On my system, this preserves the access permissions and ownership. > > And if you m

Re: "Cloning" file attributes and permissions

2007-04-12 Thread attn . steven . kuo
On Apr 12, 4:09 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] escreveu: > > > > > On Apr 12, 9:20 am, Paulo da Silva <[EMAIL PROTECTED]> wrote: > >> Hi! > > >> I need to process a file to produce another file that *must* have > >> *exactly* the same attributes and permissions of

Re: "Cloning" file attributes and permissions

2007-04-12 Thread Paulo da Silva
[EMAIL PROTECTED] escreveu: > On Apr 12, 9:20 am, Paulo da Silva <[EMAIL PROTECTED]> wrote: >> Hi! >> >> I need to process a file to produce another file that *must* have >> *exactly* the same attributes and permissions of the former. What is the >> best way to do this? The file must not exist with

Re: "Cloning" file attributes and permissions

2007-04-12 Thread attn . steven . kuo
On Apr 12, 9:20 am, Paulo da Silva <[EMAIL PROTECTED]> wrote: > Hi! > > I need to process a file to produce another file that *must* have > *exactly* the same attributes and permissions of the former. What is the > best way to do this? The file must not exist with contents (it may exist > empty) un

Re: "Cloning" file attributes and permissions

2007-04-12 Thread Kevin Kelley
The os module has this ability: http://docs.python.org/lib/os-file-dir.html -- Kevin Kelley On 4/12/07, Paulo da Silva <[EMAIL PROTECTED]> wrote: Hi! I need to process a file to produce another file that *must* have *exactly* the same attributes and permissions of the former. What is the best

"Cloning" file attributes and permissions

2007-04-12 Thread Paulo da Silva
Hi! I need to process a file to produce another file that *must* have *exactly* the same attributes and permissions of the former. What is the best way to do this? The file must not exist with contents (it may exist empty) unless it has the same attributes and permissions. I know how to do this us