display error message when python binary not found
This commit is contained in:
parent
78a7e5cbcb
commit
a92ebad2f2
1 changed files with 11 additions and 12 deletions
21
WakaTime.py
21
WakaTime.py
|
@ -89,17 +89,16 @@ def prompt_api_key():
|
||||||
|
|
||||||
|
|
||||||
def python_binary():
|
def python_binary():
|
||||||
python = 'python'
|
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
|
try:
|
||||||
|
Popen(['pythonw', '--version'])
|
||||||
|
return 'pythonw'
|
||||||
|
except:
|
||||||
for path in glob.iglob('/python*'):
|
for path in glob.iglob('/python*'):
|
||||||
if exists(realpath(join(path, 'pythonw.exe'))):
|
if exists(realpath(join(path, 'pythonw.exe'))):
|
||||||
return realpath(join(path, 'pythonw'))
|
return realpath(join(path, 'pythonw'))
|
||||||
try:
|
return None
|
||||||
python = 'pythonw'
|
return 'python'
|
||||||
Popen([python, '--version'])
|
|
||||||
except:
|
|
||||||
python = None
|
|
||||||
return python
|
|
||||||
|
|
||||||
|
|
||||||
def enough_time_passed(now):
|
def enough_time_passed(now):
|
||||||
|
@ -166,12 +165,10 @@ class SendActionThread(threading.Thread):
|
||||||
print(cmd)
|
print(cmd)
|
||||||
code = wakatime.main(cmd)
|
code = wakatime.main(cmd)
|
||||||
if code != 0:
|
if code != 0:
|
||||||
print('Error: Response code %d from wakatime package.' % code)
|
print('Error: Response code %d from wakatime package' % code)
|
||||||
else:
|
else:
|
||||||
python = python_binary()
|
python = python_binary()
|
||||||
if not python:
|
if python:
|
||||||
print('Error: Could not find python binary.')
|
|
||||||
else:
|
|
||||||
cmd.insert(0, python)
|
cmd.insert(0, python)
|
||||||
if self.debug:
|
if self.debug:
|
||||||
print(cmd)
|
print(cmd)
|
||||||
|
@ -180,6 +177,8 @@ class SendActionThread(threading.Thread):
|
||||||
else:
|
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)
|
||||||
|
else:
|
||||||
|
print('Error: Unable to find python binary.')
|
||||||
|
|
||||||
|
|
||||||
def plugin_loaded():
|
def plugin_loaded():
|
||||||
|
|
Loading…
Reference in a new issue