[python-win32] checking file permission on network share

Ben Timby btimby at gmail.com
Thu Sep 1 19:29:03 CEST 2011


On Wed, Aug 31, 2011 at 8:38 AM, Steffen Frömer
<steffen.froemer at gns-systems.de> wrote:
> Hello,
>
> i try to check, if a file on network-share is read only. I tried different
> ways.

Not the prettiest, but if you want to know if the SHARE is read only,
you can do a functional test.

import os, tempfile

def check_write(filename):
    try:
        fd, fn = tempfile.mkstemp(dir=os.path.dirname(filename))
        os.close(fd)
        os.remove(fn)
    except:
        return False
    else:
        return True

Does Windows Explorer show files on the share as read only when you
view their properties? It all depends on whether Samba advertises the
share's read only state via file attributes, looks like it does not.


More information about the python-win32 mailing list