mirror of
https://github.com/wakatime/sublime-wakatime.git
synced 2023-08-10 21:13:02 +03:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
4223f3575f | |||
284cdf3ce4 | |||
27afc41bf4 | |||
1fdda0d64a |
@ -3,6 +3,12 @@ History
|
|||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
||||||
|
6.0.0 (2015-12-01)
|
||||||
|
++++++++++++++++++
|
||||||
|
|
||||||
|
- use embeddable Python instead of installing on Windows
|
||||||
|
|
||||||
|
|
||||||
5.0.1 (2015-10-06)
|
5.0.1 (2015-10-06)
|
||||||
++++++++++++++++++
|
++++++++++++++++++
|
||||||
|
|
||||||
|
52
WakaTime.py
52
WakaTime.py
@ -7,7 +7,7 @@ Website: https://wakatime.com/
|
|||||||
==========================================================="""
|
==========================================================="""
|
||||||
|
|
||||||
|
|
||||||
__version__ = '5.0.1'
|
__version__ = '6.0.0'
|
||||||
|
|
||||||
|
|
||||||
import sublime
|
import sublime
|
||||||
@ -22,6 +22,7 @@ import threading
|
|||||||
import urllib
|
import urllib
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from zipfile import ZipFile
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
try:
|
try:
|
||||||
import _winreg as winreg # py2
|
import _winreg as winreg # py2
|
||||||
@ -131,6 +132,7 @@ def python_binary():
|
|||||||
|
|
||||||
# look for python in PATH and common install locations
|
# look for python in PATH and common install locations
|
||||||
paths = [
|
paths = [
|
||||||
|
os.path.join(os.path.expanduser('~'), '.wakatime', 'python'),
|
||||||
None,
|
None,
|
||||||
'/',
|
'/',
|
||||||
'/usr/local/bin/',
|
'/usr/local/bin/',
|
||||||
@ -389,28 +391,40 @@ class SendHeartbeatThread(threading.Thread):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class InstallPython(threading.Thread):
|
class DownloadPython(threading.Thread):
|
||||||
"""Non-blocking thread for installing Python on Windows machines.
|
"""Non-blocking thread for extracting embeddable Python on Windows machines.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
log(INFO, 'Downloading and installing python...')
|
log(INFO, 'Downloading embeddable Python...')
|
||||||
url = 'https://www.python.org/ftp/python/3.4.3/python-3.4.3.msi'
|
|
||||||
if platform.architecture()[0] == '64bit':
|
ver = '3.5.0'
|
||||||
url = 'https://www.python.org/ftp/python/3.4.3/python-3.4.3.amd64.msi'
|
arch = 'amd64' if platform.architecture()[0] == '64bit' else 'win32'
|
||||||
python_msi = os.path.join(os.path.expanduser('~'), 'python.msi')
|
url = 'https://www.python.org/ftp/python/{ver}/python-{ver}-embed-{arch}.zip'.format(
|
||||||
|
ver=ver,
|
||||||
|
arch=arch,
|
||||||
|
)
|
||||||
|
|
||||||
|
if not os.path.exists(os.path.join(os.path.expanduser('~'), '.wakatime')):
|
||||||
|
os.makedirs(os.path.join(os.path.expanduser('~'), '.wakatime'))
|
||||||
|
|
||||||
|
zip_file = os.path.join(os.path.expanduser('~'), '.wakatime', 'python.zip')
|
||||||
try:
|
try:
|
||||||
urllib.urlretrieve(url, python_msi)
|
urllib.urlretrieve(url, zip_file)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
urllib.request.urlretrieve(url, python_msi)
|
urllib.request.urlretrieve(url, zip_file)
|
||||||
args = [
|
|
||||||
'msiexec',
|
log(INFO, 'Extracting Python...')
|
||||||
'/i',
|
with ZipFile(zip_file) as zf:
|
||||||
python_msi,
|
path = os.path.join(os.path.expanduser('~'), '.wakatime', 'python')
|
||||||
'/norestart',
|
zf.extractall(path)
|
||||||
'/qb!',
|
|
||||||
]
|
try:
|
||||||
Popen(args)
|
os.remove(zip_file)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
log(INFO, 'Finished extracting Python.')
|
||||||
|
|
||||||
|
|
||||||
def plugin_loaded():
|
def plugin_loaded():
|
||||||
@ -422,7 +436,7 @@ def plugin_loaded():
|
|||||||
if not python_binary():
|
if not python_binary():
|
||||||
log(WARNING, 'Python binary not found.')
|
log(WARNING, 'Python binary not found.')
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
thread = InstallPython()
|
thread = DownloadPython()
|
||||||
thread.start()
|
thread.start()
|
||||||
else:
|
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")
|
||||||
|
Reference in New Issue
Block a user