Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for 3125/3126 #638

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions emmet/pyv8loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@

if is_python3:
import urllib.request as url_req
import urllib.error as url_err
import urllib.parse as url_parse
# import urllib.error as url_err
# import urllib.parse as url_parse
url_err = ''
url_parse = ''
else:
import urllib
import urllib2
Expand All @@ -36,7 +38,7 @@ def load(dest_path, delegate=None):
Main function that attempts to load or update PyV8 binary.
First, it loads list of available PyV8 modules and check if
PyV8 should be downloaded or updated.
@param dest_path: Path where PyV8 lib should be downloaded
@param dest_path: Path where PyV8 lib should be downloaded
@param delegate: instance of LoaderDelegate that will receive
loader progress events
@returns: `True` if download progress was initiated
Expand All @@ -55,9 +57,9 @@ def load(dest_path, delegate=None):
def on_complete(result, *args, **kwargs):
if result is not None:
# Most recent version was downloaded
config['last_id'] = result
config['last_id'] = result
if 'PyV8' not in sys.modules:
# PyV8 is not loaded yet, we can safely unpack it
# PyV8 is not loaded yet, we can safely unpack it
unpack_pyv8(dest_path)

config['last_update'] = time.time()
Expand Down Expand Up @@ -85,7 +87,7 @@ def on_complete(result, *args, **kwargs):
thread.start()

delegate.on_start()

# watch on download progress
prog = ThreadProgress(thread, delegate, thread_exists)
prog.on('complete', on_complete if not thread_exists else delegate.on_complete)
Expand Down Expand Up @@ -127,7 +129,7 @@ def get_loader_config(path):

def save_loader_config(path, data):
config_path = os.path.join(path, 'config.json')

if not os.path.exists(path):
os.makedirs(path)
fp = open(config_path, 'w')
Expand Down Expand Up @@ -269,7 +271,7 @@ def run(self):
if not self.thread.is_alive():
if self.thread.exit_code != 0:
return self.trigger('error', exit_code=self.thread.exit_code, progress=self)

return self.trigger('complete', result=self.thread.result, progress=self)

self.trigger('progress', progress=self)
Expand Down Expand Up @@ -584,11 +586,11 @@ def run(self):
os.makedirs(self.download_path)
except Exception as e:
pass

fp = open(os.path.join(self.download_path, 'pack.zip'), 'wb')
fp.write(package)
fp.close()

self.result = cur_item['sha']
# Done!