Skip to content

Commit 7bbe1a5

Browse files
committed
#5681 auto resolve python3 binary if available
1 parent 135c123 commit 7bbe1a5

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

lib/Common.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,16 @@ Common.sink.resolveInterpreter = function(app) {
447447
// No interpreter defined and correspondance in schema hashmap
448448
if (noInterpreter && betterInterpreter) {
449449
app.exec_interpreter = betterInterpreter;
450+
451+
if (betterInterpreter == "python") {
452+
if (which('python') == null)
453+
if (which('python3') == null) {
454+
Common.printError(cst.PREFIX_MSG_WARNING + chalk.bold.yellow('python and python3 binaries not available in PATH'));
455+
}
456+
else {
457+
app.exec_interpreter = 'python3';
458+
}
459+
}
450460
}
451461
// Else if no Interpreter detect if process is binary
452462
else if (noInterpreter)

test/e2e/cli/cli-actions-2.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,14 @@ spec "stderr cb written"
138138

139139
$pm2 delete all
140140

141-
# ## #2350 verify all script have been killed
142-
# $pm2 start python-script.py
143-
# $pm2 start echo.js
144-
# should 'should app be online' 'online' 2
141+
## #2350 verify all script have been killed
142+
$pm2 start python-script.py
143+
$pm2 start echo.js
144+
should 'should app be online' 'online' 2
145145

146-
# kill `cat ~/.pm2/pm2.pid`
147-
# spec "should have killed pm2"
146+
kill `cat ~/.pm2/pm2.pid`
147+
spec "should have killed pm2"
148148

149-
# sleep 3
150-
# pgrep "python"
151-
# ispec "should python script be killed"
149+
sleep 3
150+
pgrep "python"
151+
ispec "should python script be killed"

test/fixtures/python-script.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
if __name__ == "__main__":
44
while 1:
5-
print 'Script.py: alive'
5+
print('Script.py: alive')
66
time.sleep(1)

0 commit comments

Comments
 (0)