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
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
[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
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
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
[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
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
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
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