From 1a1c52780bd45796ccaae5ac3fe2c53cf28c3e64 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 13 Mar 2018 14:46:26 +0100 Subject: [PATCH] Bugfixes --- lib/danog/PrimeModule.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/danog/PrimeModule.php b/lib/danog/PrimeModule.php index bad5b3e..5b7be83 100644 --- a/lib/danog/PrimeModule.php +++ b/lib/danog/PrimeModule.php @@ -80,8 +80,8 @@ public static function native($what) public static function python_single($what) { if (function_exists('shell_exec')) { - $res = shell_exec('timeout 10 python '.__DIR__.'/prime.py '.$what); - if ($res == '' || is_null($res)) { + $res = trim(shell_exec('timeout 10 python '.__DIR__.'/prime.py '.$what.' 2>&1')); + if ($res == '' || is_null($res) || !is_numeric($res)) { return false; } $newval = intval($res); @@ -114,8 +114,8 @@ public static function python($what) public static function python_single_alt($what) { if (function_exists('shell_exec')) { - $res = shell_exec('python '.__DIR__.'/alt_prime.py '.$what); - if ($res == '' || is_null($res)) { + $res = trim(shell_exec('python '.__DIR__.'/alt_prime.py '.$what.' 2>&1')); + if ($res == '' || is_null($res) || !is_numeric($res)) { return false; } $newval = intval($res);