From 54d9ec334578a1f8229eb1789a20843321efb8c0 Mon Sep 17 00:00:00 2001 From: Olivier <16240457+TiTidom-RC@users.noreply.github.com> Date: Sat, 13 Jun 2026 11:03:36 +0200 Subject: [PATCH] Improve Python deps checks and logging Use __CLASS__ for log tags instead of hardcoded 'tvremote' to standardize logging. Remove sudo from pip commands and add --no-cache-dir to pip invocations when checking/installing dependencies. Switch pip freeze to use shell_exec and include its output in logs for easier debugging of missing Python packages. --- core/class/tvremote.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/class/tvremote.class.php b/core/class/tvremote.class.php index ed1e85b..d9b0298 100644 --- a/core/class/tvremote.class.php +++ b/core/class/tvremote.class.php @@ -77,27 +77,27 @@ public static function dependancy_info() { } else { if (exec(system::getCmdSudo() . system::get('cmd_check') . '-Ec "python3\-requests|python3\-setuptools|python3\-dev|python3\-venv"') < 4) { $return['state'] = 'nok'; - log::add('tvremote', 'debug', '[Python-Dep] System packages missing (python3-requests, python3-setuptools, python3-dev, or python3-venv)'); + log::add(__CLASS__, 'debug', '[Python-Dep] System packages missing (python3-requests, python3-setuptools, python3-dev, or python3-venv)'); } elseif (!file_exists(self::PYTHON3_PATH)) { $return['state'] = 'nok'; - log::add('tvremote', 'debug', '[Python-Dep] Python venv executable not found at: ' . self::PYTHON3_PATH); + log::add(__CLASS__, 'debug', '[Python-Dep] Python venv executable not found at: ' . self::PYTHON3_PATH); } else { $expectedCount = config::byKey('pythonDepNum', 'tvremote', 0, true); $pythonDepString = config::byKey('pythonDepString', 'tvremote', '', true); - $cmd = system::getCmdSudo() . self::PYTHON3_PATH . ' -m pip freeze | grep -Ewci "' . $pythonDepString . '"'; + $cmd = self::PYTHON3_PATH . ' -m pip --no-cache-dir freeze | grep -Ewci "' . $pythonDepString . '"'; $foundCount = exec($cmd); if ($foundCount < $expectedCount) { $return['state'] = 'nok'; - log::add('tvremote', 'debug', '[Python-Dep] Missing Dependencies. Found: ' . $foundCount . ' / Expected: ' . $expectedCount); - log::add('tvremote', 'debug', '[Python-Dep] Regex used: ' . $pythonDepString); + log::add(__CLASS__, 'debug', '[Python-Dep] Missing Dependencies. Found: ' . $foundCount . ' / Expected: ' . $expectedCount); + log::add(__CLASS__, 'debug', '[Python-Dep] Regex used: ' . $pythonDepString); // Log actual pip freeze content for debugging - $pipFreeze = shell_exec(system::getCmdSudo() . self::PYTHON3_PATH . ' -m pip freeze'); - log::add('tvremote', 'debug', '[Python-Dep] Pip Freeze Output: ' . str_replace(PHP_EOL, ' | ', trim($pipFreeze))); + $pipFreeze = shell_exec(self::PYTHON3_PATH . ' -m pip --no-cache-dir freeze'); + log::add(__CLASS__, 'debug', '[Python-Dep] Pip Freeze Output: ' . str_replace(PHP_EOL, ' | ', trim($pipFreeze))); } else { $return['state'] = 'ok'; - log::add('tvremote', 'debug', '[Python-Dep] Dependencies installed. State : OK'); + log::add(__CLASS__, 'debug', '[Python-Dep] Dependencies installed. State : OK'); } } }