I am currently using subprocess to unpack a selection or zip files using 7zip. I have to use this unpacking method instead of the zipfile module because on occasion the zipfile corrupts shapefiles. My current method is:
try:
for file in os.listdir(downloads):
print file
expression2 = sevenzip + " e " +downloads + '\\' + file + " -oC:\Users\Oulton"
print expression2
#os.system(r"C:\Users\Oulton\7z e C:\Users\Oulton\install.zip -oC:\Users\Oulton")
subprocess.call(expression2)
except:
time.sleep(3)
traceback.print_exc()
But this is not convenient because:
- I only want to unpack certain .shp files and not all of the other junk in each zip
- A shell is opened and closed for each iteration, I would prefer the shell to stay open throughout
- I have to use manual input to overwrite duplicately named files using this method