stat, chmod and RDONLY file (win32)?
T. C. Mits
71351.356 at compuserve.com
Mon Aug 16 23:49:28 EDT 1999
(newbie alert!)
I'm writing a file directory manipulation and system utility executor in
Python, since its supposed to be a good glue scripting language.
(anything, better?)
Hitting a lot of stumbling blocks. Latest is trying to delete a directory
tree that may have files with a read-only attrib (in NT and win98). The
exception occurs in shutil.rmtree(), so I guess I'll have to cobble
something to find such files and chg the attributes. I found os.stat(),
chmod() and stat module, but the docs are a little shallow. Does the doc
for chmod(): "Change the mode of path to the numeric mode. Availability:
Unix, Windows" mean that one must supply the c-run-time bit flags,
documented elsewhere (where?), as mentioned in the open() API blurb, such as
O_RDONLY. Sorry, if this is dumb question, lately I *have* been a little
dumb. There are probably better alternatives to do a 'safe' deltree...
I wrote a little ditty to show file status, maybe?:
def fstat( name) :
print "%s: [%s]" % ( name,hex( os.stat(name)[ST_MODE] ) )
and get:
locked.txt: [0x8124]
temp.txt: [0x81b6]
----------------------------------------------------------------------------
----------------------------------------------------------------------------
-------------
Hopefully, when this is working and must be used on Unix, there will be no
code changes necessary, right? : )
More information about the Python-list
mailing list