only use pythonw.exe on Windows platform and display error in Sublime Console instead of using python.exe

This commit is contained in:
Alan Hamlett 2013-10-12 21:52:40 -07:00
parent 5616206b48
commit 78a7e5cbcb

View File

@ -91,14 +91,14 @@ def prompt_api_key():
def python_binary(): def python_binary():
python = 'python' python = 'python'
if platform.system() == 'Windows': if platform.system() == 'Windows':
python = 'pythonw' for path in glob.iglob('/python*'):
if exists(realpath(join(path, 'pythonw.exe'))):
return realpath(join(path, 'pythonw'))
try: try:
python = 'pythonw'
Popen([python, '--version']) Popen([python, '--version'])
except: except:
for path in glob.iglob('/python*'): python = None
if exists(realpath(join(path, 'pythonw.exe'))):
python = realpath(join(path, 'pythonw'))
break
return python return python
@ -166,16 +166,20 @@ 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:
cmd.insert(0, python_binary()) python = python_binary()
if self.debug: if not python:
print(cmd) print('Error: Could not find python binary.')
if platform.system() == 'Windows':
Popen(cmd, shell=False)
else: else:
with open(join(expanduser('~'), '.wakatime.log'), 'a') as stderr: cmd.insert(0, python)
Popen(cmd, stderr=stderr) if self.debug:
print(cmd)
if platform.system() == 'Windows':
Popen(cmd, shell=False)
else:
with open(join(expanduser('~'), '.wakatime.log'), 'a') as stderr:
Popen(cmd, stderr=stderr)
def plugin_loaded(): def plugin_loaded():