Skip to content
Snippets Groups Projects

Env variables in yaml config

Merged Ole Binder requested to merge develop into main
3 files
+ 16
16
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -54,7 +54,7 @@ class Recorder:
The default config file is 'config/engine-recorder.yaml'
"""
def __init__(self, name: str = "AuRa_Recorder", config_file: str = None):
def __init__(self, name: str = "AuRa_Recorder", config_file: str | None = None):
"""Inits Recorder with AuRa_Recorder or another name if given."""
self._home_path = os.path.expanduser("~")
self._recorder_root = os.path.dirname(
@@ -64,7 +64,6 @@ class Recorder:
if not config_file:
config_file = os.path.join(self._recorder_root, "config/engine-recorder.yaml")
self.config_file = config_file
self._recorder_cmd = None
self._stop_recording = False
self.archiver = None
@@ -110,7 +109,7 @@ class Recorder:
self.logger.error("Could not create virtual audio device.")
sys.exit(1)
self._recorder_cmd = self.build_record_command(self.config.recorder)
self.recorder_cmd = self.build_record_command(self.config.recorder)
# we could allow the user to change this
store_dir_sub_dir_strftime = "%Y/%m/%d"
@@ -227,16 +226,17 @@ class Recorder:
"""Starts the recording process.
This makes a call to subprocess.Popen and starts a process according to
self._recorder_cmd.
self.recorder_cmd.
"""
signal.signal(signal.SIGINT, self._exit_graceful)
signal.signal(signal.SIGTERM, self._exit_graceful)
cmd_string = '" "'.join(self._recorder_cmd[1:])
self.logger.info(f'Try to start recorder with: {self._recorder_cmd[0]} "{cmd_string}"')
command_list = self.recorder_cmd
cmd_string = '" "'.join(command_list[1:])
self.logger.info(f'Try to start recorder with: {command_list[0]} "{cmd_string}"')
return_code = 0
try:
with subprocess.Popen(
self._recorder_cmd,
command_list,
text=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
@@ -276,14 +276,14 @@ class Recorder:
return_code = 1
except subprocess.CalledProcessError as cpe:
self.logger.error(
f"Could not start recorder. \n{cpe.stderr}\n{' '.join(self._recorder_cmd)}"
f"Could not start recorder. \n{cpe.stderr}\n{' '.join(command_list)}"
)
self.logger.error(f"Exiting: {cpe.returncode}")
return_code = cpe.returncode
except FileNotFoundError as fnfe:
self.logger.error(
f"Process failed to start because ffmpeg could not be found."
f"\n{' '.join(self._recorder_cmd)}\n{fnfe}"
f"\n{' '.join(command_list)}\n{fnfe}"
)
return_code = 1
finally:
@@ -327,7 +327,7 @@ class Recorder:
"""
return os.path.isdir(dir) and os.access(dir, os.W_OK)
def get_validated_store_dir(self, store_dir: str) -> str:
def get_validated_store_dir(self, store_dir: str) -> str | None:
"""Check if the store_dir is set, if so validate it.
If store_dir is None use the standard directory.
@@ -578,7 +578,7 @@ class Recorder:
config.file.segment_time,
"-strftime",
"1",
f"{config.file.store_dir}/%Y/%m/%d/{config.file.strftime}.{config.file.format}",
f"{config.file.store_dir}/%Y/%m/%d/{config.file.strftime}_%s.{config.file.format}",
]
# remove all empty strings and return the list
Loading