Skip to content

Commit

Permalink
Fix selecting a custom recording location (--spool)
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Jun 20, 2021
1 parent 33f632e commit 421c170
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions doc/backlog.rst
Expand Up @@ -7,3 +7,4 @@ Saraswati backlog
- [o] Upload files and purge from local disk
- [o] Record for a maximum number of settings, using GSt's ``num-buffers=``
- [o] What about `muxer.audio_1`?
- [o] Run as system daemon
16 changes: 12 additions & 4 deletions saraswati/cli.py
Expand Up @@ -21,9 +21,13 @@
# Record two channels with different sine waves.
saraswati record \\
--channel="channel1 source=audiotestsrc wave=3 freq=200; foo=bar" \\
--channel="channel2 source=audiotestsrc wave=3 freq=400" \\
--channel="channel2 source=audiotestsrc wave=3 freq=400"
# Record to a specified location, using a different chunk duration.
saraswati record \\
--channel="testdrive source=autoaudiosrc" \\
--chunk-duration=10 \\
[--spool=/var/spool/saraswati]
--spool=/var/spool/saraswati
"""


Expand Down Expand Up @@ -70,6 +74,7 @@ def validate_channel(ctx, param, value):
)
spool_opt = click.option(
"--spool",
"spool_path",
type=click.Path(exists=True, file_okay=False, dir_okay=True, writable=True),
help="Absolute path to the spool directory",
)
Expand Down Expand Up @@ -155,7 +160,7 @@ def record(
channels: List[Channel],
chunk_duration: int,
chunk_max_files: int,
spool: str,
spool_path: str,
debug: bool,
):

Expand All @@ -164,7 +169,10 @@ def record(

# Create settings container.
settings = SaraswatiSettings(
channels=None, chunk_duration=chunk_duration, chunk_max_files=chunk_max_files
channels=None,
chunk_duration=chunk_duration,
chunk_max_files=chunk_max_files,
spool_path=spool_path,
)

# Ensure spool directory exists.
Expand Down
4 changes: 3 additions & 1 deletion saraswati/model.py
Expand Up @@ -33,7 +33,9 @@ class SaraswatiSettings:
upload_interval: Optional[int] = None

def __post_init__(self):
if self.spool_path is None:
if self.spool_path is not None:
self.spool_path = Path(self.spool_path)
else:
from saraswati import __appname__

self.spool_path = Path(user_data_dir(__appname__, "hiveeyes")) / "spool"
Expand Down

0 comments on commit 421c170

Please sign in to comment.