log output from wakatime-cli when in debug mode

This commit is contained in:
Alan Hamlett 2016-01-01 23:06:03 -08:00
parent a97792c23c
commit c537044801

View File

@ -271,18 +271,18 @@ def find_python_in_folder(folder, headless=True):
if folder is not None: if folder is not None:
path = os.path.realpath(os.path.join(folder, 'python')) path = os.path.realpath(os.path.join(folder, 'python'))
if headless: if headless:
path = path + 'w' path = u(path) + u('w')
log(DEBUG, 'Looking for Python at: {0}'.format(path)) log(DEBUG, u('Looking for Python at: {0}').format(path))
try: try:
process = Popen([path, '--version'], stdout=PIPE, stderr=STDOUT) process = Popen([path, '--version'], stdout=PIPE, stderr=STDOUT)
output, err = process.communicate() output, err = process.communicate()
output = u(output).strip() output = u(output).strip()
retcode = process.poll() retcode = process.poll()
log(DEBUG, 'Python Version Output: {0}'.format(output)) log(DEBUG, u('Python Version Output: {0}').format(output))
if not retcode and pattern.search(output): if not retcode and pattern.search(output):
return path return path
except: except:
log(DEBUG, 'Python Version Output: {0}'.format(u(sys.exc_info()[1]))) log(DEBUG, u('Python Version Output: {0}').format(u(sys.exc_info()[1])))
if headless: if headless:
path = find_python_in_folder(folder, headless=False) path = find_python_in_folder(folder, headless=False)
@ -416,12 +416,23 @@ class SendHeartbeatThread(threading.Thread):
if python_binary(): if python_binary():
cmd.insert(0, python_binary()) cmd.insert(0, python_binary())
log(DEBUG, ' '.join(obfuscate_apikey(cmd))) log(DEBUG, ' '.join(obfuscate_apikey(cmd)))
if platform.system() == 'Windows': try:
Popen(cmd) if not self.debug:
else: Popen(cmd)
with open(os.path.join(os.path.expanduser('~'), '.wakatime.log'), 'a') as stderr: self.sent()
Popen(cmd, stderr=stderr) else:
self.sent() process = Popen(cmd, stdout=PIPE, stderr=STDOUT)
output, err = process.communicate()
output = u(output)
retcode = process.poll()
if (not retcode or retcode == 102) and not output:
self.sent()
if retcode:
log(DEBUG if retcode == 102 else ERROR, 'wakatime-core exited with status: {0}'.format(retcode))
if output:
log(ERROR, u('wakatime-core output: {0}').format(output))
except:
log(ERROR, u(sys.exc_info()[1]))
else: else:
log(ERROR, 'Unable to find python binary.') log(ERROR, 'Unable to find python binary.')