diff --git a/lib/danog/PrimeModule.php b/lib/danog/PrimeModule.php index 789aab8..daba262 100644 --- a/lib/danog/PrimeModule.php +++ b/lib/danog/PrimeModule.php @@ -89,10 +89,10 @@ class PrimeModule public static function python_single($what) { if (function_exists('shell_exec')) { - $res = trim(shell_exec('timeout 10 python2 '.__DIR__.'/prime.py '.$what.' 2>&1')); + $res = trim(shell_exec('timeout 10 python2 '.__DIR__.'/prime.py '.$what.' 2>&1') ?? ''); if ($res == '' || is_null($res) || !is_numeric($res)) { copy(__DIR__.'/prime.py', getcwd().'/.prime.py'); - $res = trim(shell_exec('timeout 10 python2 '.getcwd().'/.prime.py '.$what.' 2>&1')); + $res = trim(shell_exec('timeout 10 python2 '.getcwd().'/.prime.py '.$what.' 2>&1') ?? ''); unlink(getcwd().'/.prime.py'); if ($res == '' || is_null($res) || !is_numeric($res)) { return false; @@ -128,10 +128,10 @@ class PrimeModule public static function python_single_alt($what) { if (function_exists('shell_exec')) { - $res = trim(shell_exec('python '.__DIR__.'/alt_prime.py '.$what.' 2>&1')); + $res = trim(shell_exec('python '.__DIR__.'/alt_prime.py '.$what.' 2>&1') ?? ''); if ($res == '' || is_null($res) || !is_numeric($res)) { copy(__DIR__.'/alt_prime.py', getcwd().'/.alt_prime.py'); - $res = trim(shell_exec('python '.getcwd().'/.alt_prime.py '.$what.' 2>&1')); + $res = trim(shell_exec('python '.getcwd().'/.alt_prime.py '.$what.' 2>&1') ?? ''); unlink(getcwd().'/.alt_prime.py'); if ($res == '' || is_null($res) || !is_numeric($res)) { return false; diff --git a/tests/install_deps.sh b/tests/install_deps.sh index 936a566..a9accd7 100755 --- a/tests/install_deps.sh +++ b/tests/install_deps.sh @@ -1,17 +1,5 @@ #!/bin/bash -export PATH=$PATH:~/.phpenv/versions/$(phpenv version-name)/bin -cd /tmp && -git clone https://github.com/CopernicaMarketingSoftware/PHP-CPP && -cd PHP-CPP && -make -j16 && -sudo make install && - -cd ../ && -git clone https://github.com/danog/PrimeModule-ext && -cd PrimeModule-ext && -make -j16 && -echo "extension=$PWD/primemodule.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini && -cd .. +sudo apt-get install build-essential && git clone https://github.com/danog/PrimeModule-ext && cd PrimeModule-ext && make -j$(nproc) && sudo make install exit 0