Skip to content

Instantly share code, notes, and snippets.

@kieranjol
Created March 26, 2018 15:11
Show Gist options
  • Select an option

  • Save kieranjol/e2bae8ea11444a404d4750943f135512 to your computer and use it in GitHub Desktop.

Select an option

Save kieranjol/e2bae8ea11444a404d4750943f135512 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from zipfile import ZipFile
import zipfile
import sys
import os
import time
import datetime
def main():
pwd = os.getcwd()
source = sys.argv[1]
# destination = sys.argv[2]
start = datetime.datetime.now()
with ZipFile('compression.zip', 'w',zipfile.ZIP_STORED, allowZip64 = True) as myzip:
os.chdir(source)
for root, dirnames, filenames in os.walk(source):
for filename in filenames:
full_path = os.path.relpath(os.path.join(root, filename))
print 'zipping %s' % full_path
myzip.write(full_path)
finish = datetime.datetime.now()
print start, finish
os.chdir(pwd)
start = datetime.datetime.now()
time.sleep(45)
with zipfile.ZipFile('compression.zip', 'r') as myzip:
print 'verifying..'
print myzip.testzip()
finish = datetime.datetime.now()
print start, finish
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment