prefer python3 when running wakatime-cli
This commit is contained in:
parent
11d8fc3a09
commit
9eac8e2bd3
1 changed files with 12 additions and 6 deletions
18
WakaTime.py
18
WakaTime.py
|
@ -305,13 +305,15 @@ def find_python_from_registry(location, reg=None):
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
|
||||||
def find_python_in_folder(folder, headless=True):
|
def find_python_in_folder(folder, python3=True, headless=True):
|
||||||
pattern = re.compile(r'\d+\.\d+')
|
pattern = re.compile(r'\d+\.\d+')
|
||||||
|
|
||||||
path = 'python'
|
path = 'python'
|
||||||
if folder is not None:
|
if folder:
|
||||||
path = os.path.realpath(os.path.join(folder, 'python'))
|
path = os.path.realpath(os.path.join(folder, 'python'))
|
||||||
if headless:
|
if python3:
|
||||||
|
path = u(path) + u('3')
|
||||||
|
elif headless:
|
||||||
path = u(path) + u('w')
|
path = u(path) + u('w')
|
||||||
log(DEBUG, u('Looking for Python at: {0}').format(u(path)))
|
log(DEBUG, u('Looking for Python at: {0}').format(u(path)))
|
||||||
try:
|
try:
|
||||||
|
@ -325,9 +327,13 @@ def find_python_in_folder(folder, headless=True):
|
||||||
except:
|
except:
|
||||||
log(DEBUG, u(sys.exc_info()[1]))
|
log(DEBUG, u(sys.exc_info()[1]))
|
||||||
|
|
||||||
if headless:
|
if python3:
|
||||||
path = find_python_in_folder(folder, headless=False)
|
path = find_python_in_folder(folder, python3=False, headless=headless)
|
||||||
if path is not None:
|
if path:
|
||||||
|
return path
|
||||||
|
elif headless:
|
||||||
|
path = find_python_in_folder(folder, python3=python3, headless=False)
|
||||||
|
if path:
|
||||||
return path
|
return path
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in a new issue