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():
|
||||
python = 'python'
|
||||
if platform.system() == 'Windows':
|
||||
try:
|
||||
Popen(['pythonw', '--version'])
|
||||
return 'pythonw'
|
||||
except:
|
||||
for path in glob.iglob('/python*'):
|
||||
if exists(realpath(join(path, 'pythonw.exe'))):
|
||||
return realpath(join(path, 'pythonw'))
|
||||
try:
|
||||
python = 'pythonw'
|
||||
Popen([python, '--version'])
|
||||
except:
|
||||
python = None
|
||||
return python
|
||||
return None
|
||||
return 'python'
|
||||
|
||||
|
||||
def enough_time_passed(now):
|
||||
|
@ -166,12 +165,10 @@ class SendActionThread(threading.Thread):
|
|||
print(cmd)
|
||||
code = wakatime.main(cmd)
|
||||
if code != 0:
|
||||
print('Error: Response code %d from wakatime package.' % code)
|
||||
print('Error: Response code %d from wakatime package' % code)
|
||||
else:
|
||||
python = python_binary()
|
||||
if not python:
|
||||
print('Error: Could not find python binary.')
|
||||
else:
|
||||
if python:
|
||||
cmd.insert(0, python)
|
||||
if self.debug:
|
||||
print(cmd)
|
||||
|
@ -180,6 +177,8 @@ class SendActionThread(threading.Thread):
|
|||
else:
|
||||
with open(join(expanduser('~'), '.wakatime.log'), 'a') as stderr:
|
||||
Popen(cmd, stderr=stderr)
|
||||
else:
|
||||
print('Error: Unable to find python binary.')
|
||||
|
||||
|
||||
def plugin_loaded():
|
||||
|
|
Loading…
Reference in a new issue