Reputation: 579
I have a very simple zipfile implementation in python which succeeds at extracting from certain zip files but fails consistently on other files. When it succeeds (obviously) the code executes and the files are extracted from the zip. When it fails the code also executes without any error but the files are NOT extracted from the zip.
Any ideas as to how I might investigate why the code is executing without error, but not actually extracting the files in those cases? I have tried testing the file with is_zipfile and also compress_type and those things look the same whether I am operating on a zipfile that ultimately works or one that consistently fails. So I am not sure how to pinpoint what the 'difference' is in the files that fail.
import zipfile
def unzip(ziph):
ziph.extractall('C:\\')
if __name__ == '__main__':
ziph = zipfile.ZipFile('foo.zip', 'r')
unzip(ziph)
ziph.close()
The last thing I can add is that both extract and extractall work on the files that work, and both fail to extract (but execute without error) on the zipfiles that fail. Python 2.76 ...not sure what else to include.
Upvotes: 2
Views: 1224
Reputation: 1
Please try with =>
def unzip(ziph):
ziph.extractall(path = 'C:\\')
Also, check the permissions - if you are running the process in admin mode. You can try that by checking to write a simple text file at that path from your as well.
Upvotes: 0