Skip to content

ConfigReader: normalize the case of enum-like capture options - #971

Open
Cybis320 wants to merge 2 commits into
CroatianMeteorNetwork:prereleasefrom
Cybis320:config-value-case-normalization
Open

ConfigReader: normalize the case of enum-like capture options#971
Cybis320 wants to merge 2 commits into
CroatianMeteorNetwork:prereleasefrom
Cybis320:config-value-case-normalization

Conversation

@Cybis320

Copy link
Copy Markdown
Contributor

Config option names are case-insensitive (RawConfigParser lowercases keys), but values are read raw, while several are compared against lowercase or uppercase string literals. A value with the wrong case doesn't raise — it silently falls through to the other branch, so the station runs in a mode its config doesn't describe.

The clearest example is protocol:

config.protocol = parser.get(section, "protocol")   # ConfigReader.py

if self.config.protocol == 'udp':                   # BufferedCapture.py
    protocol_str = f"protocols=udp {common_timeouts}"
else:
    protocol_str = f"protocols=tcp {common_timeouts}"

protocol: UDP captures over TCP, and ObservationSummary still reports protocol_in_use as "UDP" — so the summary disagrees with what GStreamer actually did.

Five options are affected. Each is now normalized where it's parsed:

Option Compared against Normalization
protocol 'udp' (BufferedCapture.py) .strip().lower()
media_backend 'gst', 'v4l2' (BufferedCapture.py) .strip().lower()
frame_cleanup 'delete', 'tar' (Reprocess.py) .strip().lower()
frame_file_type 'png' (RawFrameSave.py) .strip().lower()
gst_colorspace 'GRAY8' (BufferedCapture.py) .strip().upper()

gst_colorspace goes the other way on purpose: it is interpolated into GStreamer caps as format=..., and those format names are uppercase.

Deliberately left alone:

  • ff_format — used as a literal filename extension, so forcing case would change files on disk.
  • All *_file / *_dir / *_path options — filesystem paths, case-sensitive on Linux.
  • shower_color_map, sporadic_color — matplotlib names, case-sensitive there.
  • gst_decoder — passed straight through as a GStreamer element name, never compared to a literal here.

Note that section headers ([Capture], [MeteorDetection], …) remain case-sensitive; has_section matches exactly, so a mis-cased header silently skips the whole section. That's a broader change and isn't touched here.

Testing

Parsed the shipped .config unmodified — values unchanged (tcp, gst, BGR, jpg, delete). Parsed a copy with protocol: UDP (trailing spaces), media_backend: GST, gst_colorspace: gray8, frame_file_type: PNG, frame_cleanup: Delete — all five resolve to the canonical form the consumers expect.

@dvida

dvida commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Follow-up pushed in bcc412d to address the GStreamer format-casing review finding.

Extent of the change:

  • The production adjustment is limited to gst_colorspace parsing: whitespace is trimmed, the RMS-supported bgr and gray8 spellings are canonicalized to BGR and GRAY8, and all other GStreamer format tokens retain their exact case.
  • The original lower-case normalization for protocol, media_backend, frame_file_type, and frame_cleanup is unchanged.
  • Added focused ConfigReader regression coverage for all five options and for case-sensitive GStreamer formats (RGBx, xRGB, v210, and r210).

Validation completed:

  • python -m pytest Tests/test_ConfigReader.py -q: 5 passed.
  • The shipped .config still parses as tcp, gst, BGR, jpg, and delete.
  • GStreamer caps smoke test: canonical RGBx succeeds; altered RGBX fails negotiation, confirming that preserving case is required.
  • git diff --check: clean.

@Cybis320, please review this follow-up and test it on your GStreamer/station setup, particularly the BGR/GRAY8 normalization and any case-sensitive color-space value you use. Please report the result here.

@Cybis320

Copy link
Copy Markdown
Contributor Author

Changes look good to me.

Follow-up pushed in bcc412d to address the GStreamer format-casing review finding.

@Cybis320, please review this follow-up and test it on your GStreamer/station setup, particularly the BGR/GRAY8 normalization and any case-sensitive color-space value you use. Please report the result here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants