Skip to content

Commit

Permalink
Default [webcam] section in case the config file is blank
Browse files Browse the repository at this point in the history
  • Loading branch information
makerbase committed Sep 2, 2024
1 parent 31ca2e9 commit 3965411
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions moonraker_obico/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,17 @@ def load_from_config_file(self):
)

self.webcams = []
webcam_sections = [section for section in config.sections() if section.startswith("webcam")]
if len(webcam_sections) == 0:
_logger.warn('No webcam configs found. Creating default config.')
self._config.add_section('webcam')
self.write()
webcam_sections = [section for section in config.sections() if section.startswith("webcam")]

is_primary_camera = True # First webcam is primary
for section in config.sections():
if section.startswith("webcam"):
self.webcams.append(WebcamConfig(webcam_config_section=config[section], is_primary_camera=is_primary_camera))
is_primary_camera = False
for section in webcam_sections:
self.webcams.append(WebcamConfig(webcam_config_section=config[section], is_primary_camera=is_primary_camera))
is_primary_camera = False

self.logging = LoggingConfig(
path=config.get(
Expand Down

0 comments on commit 3965411

Please sign in to comment.