mirror of
https://github.com/wakatime/sublime-wakatime.git
synced 2023-08-10 21:13:02 +03:00
find python binary on Windows even if not in system path
This commit is contained in:
parent
8d259a6c00
commit
998d0b2066
@ -47,15 +47,30 @@ if not isfile(join(expanduser('~'), '.wakatime.conf')):
|
|||||||
sublime.active_window().show_input_panel('Enter your WakaTi.me api key:', '', got_key, None, None)
|
sublime.active_window().show_input_panel('Enter your WakaTi.me api key:', '', got_key, None, None)
|
||||||
|
|
||||||
|
|
||||||
|
def python_binary():
|
||||||
|
python = 'python'
|
||||||
|
if platform.system() == 'Windows':
|
||||||
|
try:
|
||||||
|
Popen([python, '--version'])
|
||||||
|
except:
|
||||||
|
for path in glob.iglob('/python*'):
|
||||||
|
if exists(realpath(join(path, 'python.exe'))):
|
||||||
|
python = realpath(join(path, 'python'))
|
||||||
|
break
|
||||||
|
try:
|
||||||
|
Popen([python+'w', '--version'])
|
||||||
|
python = python+'w'
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return python
|
||||||
|
|
||||||
|
|
||||||
def api(targetFile, timestamp, isWrite=False, endtime=0):
|
def api(targetFile, timestamp, isWrite=False, endtime=0):
|
||||||
global LAST_ACTION, LAST_USAGE, LAST_FILE
|
global LAST_ACTION, LAST_USAGE, LAST_FILE
|
||||||
if not targetFile:
|
if not targetFile:
|
||||||
targetFile = LAST_FILE
|
targetFile = LAST_FILE
|
||||||
if targetFile:
|
if targetFile:
|
||||||
python = 'python'
|
cmd = [python_binary(), API_CLIENT,
|
||||||
if platform.system() == 'Windows' and exists(python+'w'):
|
|
||||||
python = python+'w'
|
|
||||||
cmd = [python, API_CLIENT,
|
|
||||||
'--file', targetFile,
|
'--file', targetFile,
|
||||||
'--time', str('%f' % timestamp),
|
'--time', str('%f' % timestamp),
|
||||||
'--plugin', 'sublime-wakatime/%s' % __version__,
|
'--plugin', 'sublime-wakatime/%s' % __version__,
|
||||||
@ -66,6 +81,9 @@ def api(targetFile, timestamp, isWrite=False, endtime=0):
|
|||||||
if endtime:
|
if endtime:
|
||||||
cmd.extend(['--endtime', str('%f' % endtime)])
|
cmd.extend(['--endtime', str('%f' % endtime)])
|
||||||
#print(cmd)
|
#print(cmd)
|
||||||
|
if platform.system() == 'Windows':
|
||||||
|
Popen(cmd)
|
||||||
|
else:
|
||||||
with open(join(expanduser('~'), '.wakatime.log'), 'a') as stderr:
|
with open(join(expanduser('~'), '.wakatime.log'), 'a') as stderr:
|
||||||
Popen(cmd, stderr=stderr)
|
Popen(cmd, stderr=stderr)
|
||||||
LAST_ACTION = timestamp
|
LAST_ACTION = timestamp
|
||||||
|
Loading…
Reference in New Issue
Block a user