download and install python in background thread to fix #53
This commit is contained in:
parent
c1da94bc18
commit
c50100e675
1 changed files with 28 additions and 21 deletions
49
WakaTime.py
49
WakaTime.py
|
@ -195,6 +195,8 @@ def handle_heartbeat(view, is_write=False):
|
||||||
|
|
||||||
|
|
||||||
class SendHeartbeatThread(threading.Thread):
|
class SendHeartbeatThread(threading.Thread):
|
||||||
|
"""Non-blocking thread for sending heartbeats to api.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, target_file, view, is_write=False, project=None, folders=None, force=False):
|
def __init__(self, target_file, view, is_write=False, project=None, folders=None, force=False):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
@ -274,28 +276,11 @@ class SendHeartbeatThread(threading.Thread):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def plugin_loaded():
|
class InstallPython(threading.Thread):
|
||||||
global SETTINGS
|
"""Non-blocking thread for installing Python on Windows machines.
|
||||||
print('[WakaTime] Initializing WakaTime plugin v%s' % __version__)
|
"""
|
||||||
|
|
||||||
if not python_binary():
|
def run(self):
|
||||||
print('[WakaTime] Warning: Python binary not found.')
|
|
||||||
if platform.system() == 'Windows':
|
|
||||||
install_python()
|
|
||||||
else:
|
|
||||||
sublime.error_message("Unable to find Python binary!\nWakaTime needs Python to work correctly.\n\nGo to https://www.python.org/downloads")
|
|
||||||
return
|
|
||||||
|
|
||||||
SETTINGS = sublime.load_settings(SETTINGS_FILE)
|
|
||||||
after_loaded()
|
|
||||||
|
|
||||||
|
|
||||||
def after_loaded():
|
|
||||||
if not prompt_api_key():
|
|
||||||
sublime.set_timeout(after_loaded, 500)
|
|
||||||
|
|
||||||
|
|
||||||
def install_python():
|
|
||||||
print('[WakaTime] Downloading and installing python...')
|
print('[WakaTime] Downloading and installing python...')
|
||||||
url = 'https://www.python.org/ftp/python/3.4.3/python-3.4.3.msi'
|
url = 'https://www.python.org/ftp/python/3.4.3/python-3.4.3.msi'
|
||||||
if platform.architecture()[0] == '64bit':
|
if platform.architecture()[0] == '64bit':
|
||||||
|
@ -315,6 +300,28 @@ def install_python():
|
||||||
Popen(args)
|
Popen(args)
|
||||||
|
|
||||||
|
|
||||||
|
def plugin_loaded():
|
||||||
|
global SETTINGS
|
||||||
|
print('[WakaTime] Initializing WakaTime plugin v%s' % __version__)
|
||||||
|
|
||||||
|
if not python_binary():
|
||||||
|
print('[WakaTime] Warning: Python binary not found.')
|
||||||
|
if platform.system() == 'Windows':
|
||||||
|
thread = InstallPython()
|
||||||
|
thread.start()
|
||||||
|
else:
|
||||||
|
sublime.error_message("Unable to find Python binary!\nWakaTime needs Python to work correctly.\n\nGo to https://www.python.org/downloads")
|
||||||
|
return
|
||||||
|
|
||||||
|
SETTINGS = sublime.load_settings(SETTINGS_FILE)
|
||||||
|
after_loaded()
|
||||||
|
|
||||||
|
|
||||||
|
def after_loaded():
|
||||||
|
if not prompt_api_key():
|
||||||
|
sublime.set_timeout(after_loaded, 500)
|
||||||
|
|
||||||
|
|
||||||
# need to call plugin_loaded because only ST3 will auto-call it
|
# need to call plugin_loaded because only ST3 will auto-call it
|
||||||
if ST_VERSION < 3000:
|
if ST_VERSION < 3000:
|
||||||
plugin_loaded()
|
plugin_loaded()
|
||||||
|
|
Loading…
Reference in a new issue