saysynth.cli.commands.stop
Stop currently running saysynth
processes by sequences
, tracks
, audio_devices
, and/or parent_pids
1""" 2Stop currently running `saysynth` processes by `sequences`, `tracks`, `audio_devices`, and/or `parent_pids` 3""" 4import click 5 6from saysynth.cli.colors import blue, red, yellow 7from saysynth.core import controller 8 9 10@click.command() 11@click.option( 12 "-p", 13 "--pids", 14 "parent_pid", 15 type=lambda x: [int(t.strip()) for t in x.split(",") if t.strip()], 16 help="Stop currently running `saysynth` processes by passing in the `parent_pids`", 17 default=None, 18) 19@click.option( 20 "-s", 21 "--sequences", 22 "seq", 23 type=lambda x: [t.strip() for t in x.split(",") if t.strip()], 24 help="Stop currently running `saysynth` processes by passing in the `sequence ` names", 25 default=None, 26) 27@click.option( 28 "-ad", 29 "--audio-devices", 30 "ad", 31 type=lambda x: [t.strip() for t in x.split(",") if t.strip()], 32 help="Stop currently running `saysynth` processes by passing in the `audio_devices`", 33 default=None, 34) 35@click.option( 36 "-t", 37 "--tracks", 38 "track", 39 type=lambda x: [t.strip() for t in x.split(",") if t.strip()], 40 help="Stop currently running `saysynth` processes by passing in the `track` names", 41 default=None, 42) 43def cli(**kwargs): 44 """ 45 Stop currently running `say` processes by `sequence`, `track`, `audio_device`, and/or `parent_pid` 46 """ 47 all_null = True 48 for key in ["seq", "track", "ad", "parent_pid"]: 49 vals = kwargs.get(key, None) 50 if not vals: 51 continue 52 all_null = False 53 for val in vals: 54 click.echo(f"🛑 {red('stopping')} ➡️ {yellow(key)}: {blue(val)}") 55 controller.stop_child_pids(**{key: val}) 56 if key == "parent_pid": 57 controller.rm_parent_pid(parent_pid=val) 58 if all_null: 59 click.echo(f"🛑 {red('stopping')} ➡️ {yellow('all processes')}!") 60 controller.stop_child_pids()
cli = <Command cli>
Stop currently running say
processes by sequence
, track
, audio_device
, and/or parent_pid