mirror of
https://github.com/smittix/intercept.git
synced 2026-07-17 13:58:11 -07:00
Fix acarsdec flag detection using version parsing
The previous detection logic incorrectly matched '-o' in help text for version 4.x, causing startup failures. Now properly detects version: - Version 4.0+: uses -j for JSON stdout - Version 3.x: uses -o 4 for JSON stdout Parses version from acarsdec output (e.g., "Acarsdec v4.3.1" or "Acarsdec/acarsserv 3.7") to determine the correct flag. Fixes: "invalid option -- 'o'" error on modern acarsdec builds Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
+24
-25
@@ -52,35 +52,34 @@ def find_acarsdec():
|
|||||||
def get_acarsdec_json_flag(acarsdec_path: str) -> str:
|
def get_acarsdec_json_flag(acarsdec_path: str) -> str:
|
||||||
"""Detect which JSON output flag acarsdec supports.
|
"""Detect which JSON output flag acarsdec supports.
|
||||||
|
|
||||||
Modern versions (TLeconte) use -j, very old versions used -o 4.
|
Version 4.0+ uses -j for JSON stdout.
|
||||||
Default to -j as it's the standard for current acarsdec builds.
|
Version 3.x uses -o 4 for JSON stdout.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# Try both -h and --help
|
# Get version by running acarsdec with no args (shows usage with version)
|
||||||
for help_flag in ['-h', '--help']:
|
result = subprocess.run(
|
||||||
try:
|
[acarsdec_path],
|
||||||
result = subprocess.run(
|
capture_output=True,
|
||||||
[acarsdec_path, help_flag],
|
text=True,
|
||||||
capture_output=True,
|
timeout=5
|
||||||
text=True,
|
)
|
||||||
timeout=5
|
output = result.stdout + result.stderr
|
||||||
)
|
|
||||||
help_text = result.stdout + result.stderr
|
|
||||||
|
|
||||||
# Check if -j flag is documented in help
|
# Parse version from output like "Acarsdec v4.3.1" or "Acarsdec/acarsserv 3.7"
|
||||||
if ' -j' in help_text or '\n-j' in help_text or '-j ' in help_text:
|
import re
|
||||||
return '-j'
|
version_match = re.search(r'acarsdec[^\d]*v?(\d+)\.(\d+)', output, re.IGNORECASE)
|
||||||
|
if version_match:
|
||||||
|
major = int(version_match.group(1))
|
||||||
|
# Version 4.0+ uses -j for JSON stdout
|
||||||
|
if major >= 4:
|
||||||
|
return '-j'
|
||||||
|
# Version 3.x uses -o for output mode
|
||||||
|
else:
|
||||||
|
return '-o'
|
||||||
|
except Exception as e:
|
||||||
|
logger.debug(f"Could not detect acarsdec version: {e}")
|
||||||
|
|
||||||
# Only return -o if we explicitly see it supports output modes
|
# Default to -j (modern standard for current builds from source)
|
||||||
if '-o' in help_text and 'output' in help_text.lower():
|
|
||||||
return '-o'
|
|
||||||
except Exception:
|
|
||||||
continue
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Default to -j (modern standard for TLeconte acarsdec)
|
|
||||||
# Most builds from source use this format
|
|
||||||
return '-j'
|
return '-j'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user