run_jasmine: support Python3
#!/usr/bin/env python
from __future__ import print_function
-import urllib2
+import sys
+PY3 = sys.version_info[0] == 3
+if PY3:
+ from urllib.request import urlopen
+else:
+ from urllib2 import urlopen
import shutil
import os
from os.path import join, exists, dirname, abspath
@@ -39,7 +44,12 @@ def download_jasmine_reporters():
return
if not exists(EXT_LIB):
os.mkdir(EXT_LIB)
- reporter = urllib2.urlopen(JASMINE_REPORTER_URL)
+ reporter = urlopen(JASMINE_REPORTER_URL)
+ if PY3:
+ import io
+ z = ZipFile(io.BytesIO(reporter.read()))
+ z.extractall(EXT_LIB)
+ else:
with open(join(EXT_LIB, 'tmp.zip'), 'w') as temp:
temp.write(reporter.read())
with open(join(EXT_LIB, 'tmp.zip'), 'r') as temp:
