From e204901d18c9ad5c67791c5afdc25edc96ca9d5a Mon Sep 17 00:00:00 2001 From: Smittix Date: Sun, 18 Jan 2026 10:58:28 +0000 Subject: [PATCH] Fix acarsdec JSON flag detection to prevent startup failures The get_acarsdec_json_flag() function was defaulting to the obsolete '-o' flag when detection failed, causing "invalid option -- 'o'" errors with modern acarsdec builds from TLeconte repository. Changes: - Try both -h and --help flags for better compatibility - Improve -j flag detection patterns - Default to -j (modern standard) instead of -o - Only use -o if explicitly documented in help text This fixes ACARS decoder startup failures on systems where acarsdec was built from source using setup.sh. Co-Authored-By: Claude Sonnet 4.5 --- routes/acars.py | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/routes/acars.py b/routes/acars.py index 7d91464..8a06ead 100644 --- a/routes/acars.py +++ b/routes/acars.py @@ -52,23 +52,36 @@ def find_acarsdec(): def get_acarsdec_json_flag(acarsdec_path: str) -> str: """Detect which JSON output flag acarsdec supports. - Newer forks (TLeconte) use -j, older versions use -o 4. + Modern versions (TLeconte) use -j, very old versions used -o 4. + Default to -j as it's the standard for current acarsdec builds. """ try: - result = subprocess.run( - [acarsdec_path, '-h'], - capture_output=True, - text=True, - timeout=5 - ) - help_text = result.stdout + result.stderr - # Check if -j flag is documented in help - if ' -j' in help_text or '\n-j' in help_text: - return '-j' + # Try both -h and --help + for help_flag in ['-h', '--help']: + try: + result = subprocess.run( + [acarsdec_path, help_flag], + capture_output=True, + text=True, + timeout=5 + ) + help_text = result.stdout + result.stderr + + # Check if -j flag is documented in help + if ' -j' in help_text or '\n-j' in help_text or '-j ' in help_text: + return '-j' + + # Only return -o if we explicitly see it supports output modes + if '-o' in help_text and 'output' in help_text.lower(): + return '-o' + except Exception: + continue except Exception: pass - # Default to older -o 4 syntax - return '-o' + + # Default to -j (modern standard for TLeconte acarsdec) + # Most builds from source use this format + return '-j' def stream_acars_output(process: subprocess.Popen, is_text_mode: bool = False) -> None: