forked from modem-works/dream-recorder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdreamctl
More file actions
executable file
·42 lines (36 loc) · 1.07 KB
/
dreamctl
File metadata and controls
executable file
·42 lines (36 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
import sys
import subprocess
COMMANDS = {
'config': ['python3', 'scripts/config_editor.py'],
'test': ['pytest'],
'test-cov': ['pytest', '--cov=.', '--cov-report=term-missing'],
'gpio-logs': ['tail', '-f', 'logs/gpio_service.log'],
}
HELP = """
Dream Recorder Control Script
Usage:
./dreamctl <command>
Commands:
config Edit the Dream Recorder configuration
test Run unit tests
test-cov Run unit tests with coverage report
gpio-logs Tail the GPIO service log (logs/gpio_service.log)
help Show this help message
"""
def main():
if len(sys.argv) < 2 or sys.argv[1] in ('help', '-h', '--help'):
print(HELP)
sys.exit(0)
cmd = sys.argv[1]
if cmd not in COMMANDS:
print(f"Unknown command: {cmd}\n")
print(HELP)
sys.exit(1)
docker_cmd = ['docker', 'compose', 'exec', 'app'] + COMMANDS[cmd]
try:
subprocess.run(docker_cmd, check=True)
except subprocess.CalledProcessError as e:
sys.exit(e.returncode)
if __name__ == '__main__':
main()