-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcam_cycle.py
executable file
·96 lines (69 loc) · 2.43 KB
/
cam_cycle.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env python3
"""
cam_cycle.py: cycles through the inputs.
Copyright: 2025-2025 Carl F. Karsten <[email protected]>,
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
Features:
Retrieves list of sources from vocto-core server
set_video_a #1, sleep, next
"""
import argparse
from pprint import pprint
from time import sleep
from lib.connection import Connection
from lib.corebits import VocConf, VocCmd
def sources_cycle(vc, sources, delay):
while True:
for source in sources:
vc.vocto_write(f"set_video_a {source}")
sleep(delay)
def get_args():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description="""Vocto-cycle Client
Sources are retrieved from the server.
cycle though sources.
""",
)
parser.add_argument(
"-v",
"--verbose",
action="count",
default=0,
help="Also print INFO and DEBUG messages.",
)
parser.add_argument(
"--delay",
action="store",
default=5,
type=int,
help="delay between source by this many seconds",
)
parser.add_argument(
"--host", action="store", default="localhost", help="hostname of vocto core"
)
parser.add_argument(
"--port", action="store", default=9999, help="port of vocto core"
)
parser.add_argument("--debug", action="store_true", help="debugging things.")
args = parser.parse_args()
return args
def main():
args = get_args()
# get sources:
vocconf = VocConf(args.host, args.debug)
conf = vocconf.get_server_conf()
# Pull out the list of sources
sources = conf["mix"]["sources"].split(",")
# send commands forever:
voccmd = VocCmd(args.host, args.port, args.debug)
sources_cycle(voccmd, sources, args.delay)
if __name__ == "__main__":
main()