display error message when python binary not found

This commit is contained in:
Alan Hamlett 2013-10-13 08:26:31 -07:00
parent 78a7e5cbcb
commit a92ebad2f2

View file

@ -89,17 +89,16 @@ def prompt_api_key():
def python_binary():
python = 'python'
if platform.system() == 'Windows':
for path in glob.iglob('/python*'):
if exists(realpath(join(path, 'pythonw.exe'))):
return realpath(join(path, 'pythonw'))
try:
python = 'pythonw'
Popen([python, '--version'])
Popen(['pythonw', '--version'])
return 'pythonw'
except:
python = None
return python
for path in glob.iglob('/python*'):
if exists(realpath(join(path, 'pythonw.exe'))):
return realpath(join(path, 'pythonw'))
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():