diff --git a/SARA/check_running.py b/SARA/check_running.py index fcda7e0..b41a83c 100644 --- a/SARA/check_running.py +++ b/SARA/check_running.py @@ -3,10 +3,10 @@ Check if the main loop is running /usr/bin/python3 /var/www/nebuleair_pro_4g/tests/check_running.py ''' import psutil -import subprocess +import json def is_script_running(script_name): - """Check if a given Python script is running.""" + """Check if a given Python script is currently running.""" for process in psutil.process_iter(['pid', 'cmdline']): if process.info['cmdline'] and script_name in " ".join(process.info['cmdline']): return True # Script is running @@ -14,7 +14,14 @@ def is_script_running(script_name): script_to_check = "/var/www/nebuleair_pro_4g/loop/SARA_send_data_v2.py" -if is_script_running(script_to_check): - print(f"{script_to_check} is still running.❌❌❌") -else: - print(f"{script_to_check} is NOT running.✅✅✅") +# Determine script status +is_running = is_script_running(script_to_check) + +# Create JSON response +response = { + "message": "The script is still running.❌❌❌" if is_running else "The script is NOT running.✅✅✅", + "running": is_running +} + +# Print JSON output +print(json.dumps(response, indent=4)) # Pretty print for readability diff --git a/html/launcher.php b/html/launcher.php index e698ab6..7d07375 100755 --- a/html/launcher.php +++ b/html/launcher.php @@ -44,6 +44,12 @@ if ($type == "update_config") { echo "Config updated!"; } +if ($type == "getModem_busy") { + $command = '/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/check_running.py'; + $output = shell_exec($command); + echo $output; +} + if ($type == "RTC_time") { $time = shell_exec("date '+%d/%m/%Y %H:%M:%S'"); echo $time; diff --git a/html/logs.html b/html/logs.html index d73fdcf..3840845 100755 --- a/html/logs.html +++ b/html/logs.html @@ -57,7 +57,7 @@