0

I have a small trouble with file option - executable, after using extractall.

This is my part of code:

import zipfile

archive = zipfile.ZipFile(path_to_local_folder+file, 'r')
archive.extractall(path_to_local_folder)
os.remove(path_to_local_folder+file)

In my zip archive I have a file, which should have an option - executable. Of course I can add operation "make file as executable", but I think it's not a good idea.

P.S. I use Mac OS and Python 3.5

Anton Erjomin
  • 183
  • 1
  • 1
  • 9
  • http://stackoverflow.com/questions/16249440/changing-file-permission-in-python – Paul Jun 07 '16 at 11:50
  • Yes, I know about this point, but I want to make this file as executable after operation: "extractall" – Anton Erjomin Jun 07 '16 at 11:52
  • `os.chmod(path_to_local_folder+file_name, stat.S_IXUSR)`? – Paul Jun 07 '16 at 11:54
  • unlike a tar archive; zip doesn't preserve file permissions (such as the executable bit). Though there could be extensions that allow you to store such information (check whether `unzip -Z` works in your case). – jfs Jun 07 '16 at 12:30

0 Answers0