Python creates "locked" temp dir

utabintarbo utabintarbo at gmail.com
Wed Dec 8 08:09:06 EST 2010


Thanks for the reply.

The relevant function (in a module) is as follows:

def createWorkDir(pathdir="k:\\"):
    import tempfile, os

    if os.name == 'posix':
        pathdir = os.path.join(config.get('paths', 'MOUNTPOINT'),
'subdir1')
    else:
        pathdir = os.path.normpath(r"\\windowsmount\subdir1")
    if not os.path.exists(os.path.join(pathdir,'tmp','program')):
        os.makedirs(os.path.join(pathdir,'tmp','program'))
    return os.path.normpath(tempfile.mkdtemp("", "",
os.path.join(pathdir,'tmp','program')))

The calling program calls the function as such:
    updateWorkDir = createWorkDir()

I then attempt to copy a file (using shutil.move) into updateWorkDir
and get an:

IOError: [Errno 13] Permission denied: '/MOUNTPOINT/subdir1/tmp/
program/y-Z0h3/file.ext'

I also tried to create a similar dir under 'tmp' using os.mkdir and
while the dir was not locked such that only the owner could do
anything in it, it was not writeable by anything other than the owner,
even when mode 0777 was specified explicitly.

Thanks for the help.



On Dec 8, 4:31 am, Alex Willmer <a... at moreati.org.uk> wrote:
> On Dec 7, 9:03 pm, utabintarbo <utabinta... at gmail.com> wrote:
>
> > I am using tempfile.mkdtemp() to create a working directory on a
> > remote *nix system through a Samba share. When I use this on a Windows
> > box, it works, and I have full access to the created dir. When used on
> > a Linux box (through the same Samba share), the created directory
> > shows as "locked", and I am unable to access. Obviously, I need
> > access. Any clues?
>
> You haven't provided enough details to go on.
> 1. Please post the actual code, and the trace back (if any).
> 2. When you say "I am unable to access". Do you mean another script/
> process is unable to access? If so, that is the point of mkdtemp() -
> to make a temporary directory that _only_ the creating process can
> access. If you want to share it then tempfile is not the right module
> for you.
>
> Regards, Alex




More information about the Python-list mailing list