support old Sublime Text with Python 2.6
This commit is contained in:
parent
205d4eb163
commit
08394357b7
1 changed files with 10 additions and 2 deletions
12
WakaTime.py
12
WakaTime.py
|
@ -13,6 +13,7 @@ __version__ = '7.0.12'
|
||||||
import sublime
|
import sublime
|
||||||
import sublime_plugin
|
import sublime_plugin
|
||||||
|
|
||||||
|
import contextlib
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
|
@ -20,11 +21,12 @@ import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
|
import traceback
|
||||||
import urllib
|
import urllib
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from zipfile import ZipFile
|
|
||||||
from subprocess import Popen, STDOUT, PIPE
|
from subprocess import Popen, STDOUT, PIPE
|
||||||
|
from zipfile import ZipFile
|
||||||
try:
|
try:
|
||||||
import _winreg as winreg # py2
|
import _winreg as winreg # py2
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -305,6 +307,12 @@ def find_python_from_registry(location, reg=None):
|
||||||
reg=reg,
|
reg=reg,
|
||||||
key=location,
|
key=location,
|
||||||
))
|
))
|
||||||
|
except:
|
||||||
|
log(ERROR, 'Could not read registry value "{reg}\\{key}":\n{exc}'.format(
|
||||||
|
reg=reg,
|
||||||
|
key=location,
|
||||||
|
exc=traceback.format_exc(),
|
||||||
|
))
|
||||||
|
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
@ -592,7 +600,7 @@ class DownloadPython(threading.Thread):
|
||||||
urllib.request.urlretrieve(url, zip_file)
|
urllib.request.urlretrieve(url, zip_file)
|
||||||
|
|
||||||
log(INFO, 'Extracting Python...')
|
log(INFO, 'Extracting Python...')
|
||||||
with ZipFile(zip_file) as zf:
|
with contextlib.closing(ZipFile(zip_file)) as zf:
|
||||||
path = os.path.join(resources_folder(), 'python')
|
path = os.path.join(resources_folder(), 'python')
|
||||||
zf.extractall(path)
|
zf.extractall(path)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue