update lysozyme performance script
This part never made the transition. Fixed now.
import os
import sys
import numpy
+import clint
import pickle
import zipfile
-import urllib2
+import requests
import subprocess
import matplotlib
@@ -16,7 +17,7 @@ def pickleload(filename):
"""
Does what it says. Loads a pickle (and returns it)
"""
- with open(filename, 'r') as f:
+ with open(filename, 'rb') as f:
results_dict = pickle.load(f)
return results_dict
@@ -168,27 +169,14 @@ def check_mesh():
def download_zip_with_progress_bar(url):
- file_name = url.split('/')[-1]
- u = urllib2.urlopen(url)
- f = open(file_name, 'wb')
- meta = u.info()
- file_size = int(meta.getheaders("Content-Length")[0])
- print "Downloading: %s Bytes: %s" % (file_name, file_size)
-
- file_size_dl = 0
- block_sz = 8192
- while True:
- buffer = u.read(block_sz)
- if not buffer:
- break
-
- file_size_dl += len(buffer)
- f.write(buffer)
- status = r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size)
- status = status + chr(8)*(len(status)+1)
- print status,
-
- f.close()
+ r = requests.get(url, stream=True)
+ path = url.rsplit('/', 1)[-1]
+ with open(path, 'wb') as f:
+ total_length = int(r.headers.get('content-length'))
+ for chunk in clint.textui.progress.bar(r.iter_content(chunk_size=1024), expected_size=(total_length/1024) + 1):
+ if chunk:
+ f.write(chunk)
+ f.flush()
def unzip(meshzip):
