From 7bbe1a5734b889f8796551fd31d314fac19cc755 Mon Sep 17 00:00:00 2001 From: Unitech Date: Fri, 6 Oct 2023 07:49:34 +0200 Subject: [PATCH] #5681 auto resolve python3 binary if available --- lib/Common.js | 10 ++++++++++ test/e2e/cli/cli-actions-2.sh | 18 +++++++++--------- test/fixtures/python-script.py | 2 +- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/Common.js b/lib/Common.js index 72455dbbc..065be7e6e 100644 --- a/lib/Common.js +++ b/lib/Common.js @@ -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) diff --git a/test/e2e/cli/cli-actions-2.sh b/test/e2e/cli/cli-actions-2.sh index d015b1736..c1edc5caf 100644 --- a/test/e2e/cli/cli-actions-2.sh +++ b/test/e2e/cli/cli-actions-2.sh @@ -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" diff --git a/test/fixtures/python-script.py b/test/fixtures/python-script.py index 61c77e6bd..f236f6a32 100644 --- a/test/fixtures/python-script.py +++ b/test/fixtures/python-script.py @@ -2,5 +2,5 @@ if __name__ == "__main__": while 1: - print 'Script.py: alive' + print('Script.py: alive') time.sleep(1)