Reading the access attributes of directories in Windows

vsoler vicente.soler at gmail.com
Fri Aug 20 18:54:47 EDT 2010


On Aug 20, 7:42 pm, Tim Golden <m... at timgolden.me.uk> wrote:
> On 20/08/2010 5:10 PM, vsoler wrote:
>
>
>
> > On Aug 20, 5:10 pm, Tim Golden<m... at timgolden.me.uk>  wrote:
> >> To decode the permission bit-strings to vaguely meaningful
> >> names:
>
> >> <code>
> >> import os, sys
> >> from winsys import fs
>
> >> dacl = fs.file (sys.executable).security ().dacl
> >> for permission in dacl:
> >>     print (d.trustee, " (Inherited )" if d.inherited else "")
> >>     for name in fs.FILE_ACCESS.names_from_value (d.access):
> >>       print ("  ", name)
>
> >> </code>
>
> >> TJG
>
> > it seems as though the definition of "d" is missing in your last piece
> > of code
>
> Whoops, changed tack mid-thingy. Try:
>
> dacl = ...
> for d in dacl:
>    # .. as before

Tim,

I'am testing your library. I am mainly interested in knowing the
access attributes of directories in the local(C:\) or shared unit(W:\)
of my system.

Using your script with 'c:\\' I get an error message saying... 'file
exists but it is a directory' and I cannot go any further.

Of course, the problem is that I am using "fs.file" when I should be
using something different.

Reading the doc I have found that I should be using os.walk(...),
which works, but then I cannot use fs.file

Could you please give me a hint as to what metghod I should be using?

Thank you

Vicente Soler



More information about the Python-list mailing list