mirror of
https://github.com/wakatime/sublime-wakatime.git
synced 2023-08-10 21:13:02 +03:00
install python on Windows if not already installed
This commit is contained in:
parent
d440fe912c
commit
865b0bcee9
22
WakaTime.py
22
WakaTime.py
@ -19,6 +19,7 @@ import platform
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
|
import urllib
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
@ -278,6 +279,10 @@ def plugin_loaded():
|
|||||||
print('[WakaTime] Initializing WakaTime plugin v%s' % __version__)
|
print('[WakaTime] Initializing WakaTime plugin v%s' % __version__)
|
||||||
|
|
||||||
if not python_binary():
|
if not python_binary():
|
||||||
|
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")
|
sublime.error_message("Unable to find Python binary!\nWakaTime needs Python to work correctly.\n\nGo to https://www.python.org/downloads")
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -290,6 +295,23 @@ def after_loaded():
|
|||||||
sublime.set_timeout(after_loaded, 500)
|
sublime.set_timeout(after_loaded, 500)
|
||||||
|
|
||||||
|
|
||||||
|
def install_python():
|
||||||
|
print('[WakaTime] Downloading and installing python...')
|
||||||
|
url = 'https://www.python.org/ftp/python/3.4.3/python-3.4.3.msi'
|
||||||
|
if platform.architecture()[0] == '64bit':
|
||||||
|
url = 'https://www.python.org/ftp/python/3.4.3/python-3.4.3.amd64.msi'
|
||||||
|
python_msi = os.path.join(os.path.expanduser('~'), 'python.msi')
|
||||||
|
urllib.urlretrieve(url, python_msi)
|
||||||
|
args = [
|
||||||
|
'msiexec',
|
||||||
|
'/i',
|
||||||
|
python_msi,
|
||||||
|
'/norestart',
|
||||||
|
'/qb!',
|
||||||
|
]
|
||||||
|
Popen(args)
|
||||||
|
|
||||||
|
|
||||||
# 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 New Issue
Block a user