Permissions issues with zipfile
Cameron Simpson
cs at cskk.id.au
Mon Sep 4 04:24:02 EDT 2017
On 04Sep2017 00:30, loial <jldunn2000 at gmail.com> wrote:
>I am getting a permission issue with the following code
> targetdirectory = '/data/upload'
> self.ZIPFileName = targetDirectory + os.sep + "MY.ZIP"
> zf = zipfile.ZipFile(self.ZIPFileName, mode='w')
> [Errno 13] Permission denied: '/data/upload/MY.ZIP'
>
>The target directory is an NFS mounted directory.
>
>I can manually create a file in that directory with no issues using the same user
>
>Any ideas?
>
>Python version is 2.7.10. Platform is Centos 7
Odd.
1: Does such a zip file already exist, perhaps with different ownership or no
write permission?
2: Is the code running as you? Eg do you get this error running the code by
hand from the same shell in which you can manually create a file there?
3: You're doing your python and manual check on the same machine (versus some
testing on the server and some local or something)?
You're on Linux. Install strace and see what:
strace python your-program.py
shows you. Just in case the zip file's being opened with a funny mode or
something. It is always good to be totally sure of exactly what system call is
failing.
Cheers,
Cameron Simpson <cs at cskk.id.au> (formerly cs at zip.com.au)
More information about the Python-list
mailing list