Skip to content

Commit

Permalink
#5681 auto resolve python3 binary if available
Browse files Browse the repository at this point in the history
  • Loading branch information
Unitech committed Oct 6, 2023
1 parent 135c123 commit 7bbe1a5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
10 changes: 10 additions & 0 deletions lib/Common.js
Expand Up @@ -447,6 +447,16 @@ Common.sink.resolveInterpreter = function(app) {
// No interpreter defined and correspondance in schema hashmap
if (noInterpreter && betterInterpreter) {
app.exec_interpreter = betterInterpreter;

if (betterInterpreter == "python") {
if (which('python') == null)
if (which('python3') == null) {
Common.printError(cst.PREFIX_MSG_WARNING + chalk.bold.yellow('python and python3 binaries not available in PATH'));
}
else {
app.exec_interpreter = 'python3';
}
}
}
// Else if no Interpreter detect if process is binary
else if (noInterpreter)
Expand Down
18 changes: 9 additions & 9 deletions test/e2e/cli/cli-actions-2.sh
Expand Up @@ -138,14 +138,14 @@ spec "stderr cb written"

$pm2 delete all

# ## #2350 verify all script have been killed
# $pm2 start python-script.py
# $pm2 start echo.js
# should 'should app be online' 'online' 2
## #2350 verify all script have been killed
$pm2 start python-script.py
$pm2 start echo.js
should 'should app be online' 'online' 2

# kill `cat ~/.pm2/pm2.pid`
# spec "should have killed pm2"
kill `cat ~/.pm2/pm2.pid`
spec "should have killed pm2"

# sleep 3
# pgrep "python"
# ispec "should python script be killed"
sleep 3
pgrep "python"
ispec "should python script be killed"
2 changes: 1 addition & 1 deletion test/fixtures/python-script.py
Expand Up @@ -2,5 +2,5 @@

if __name__ == "__main__":
while 1:
print 'Script.py: alive'
print('Script.py: alive')
time.sleep(1)

0 comments on commit 7bbe1a5

Please sign in to comment.