10 assert(1 <= len(s) and len(s) <= 3)
14 return int(s[0]) * 60 + int(s[1])
16 return ((int(s[0]) * 60 + int(s[1])) * 60) + int(s[2])
18 def seek(dcp_seconds):
19 print("O %s" % args.dcp)
21 test_seconds = hms_to_seconds(args.length)
22 while test_seconds > 0:
23 wait = random.randint(500, dcp_seconds * 1000)
24 # Wait some milliseconds
27 print("S %d" % random.randint(0, 4095))
28 # Make sure we're still playing
30 test_seconds -= wait / 1000
32 def repeat(dcp_seconds):
33 print("O %s" % args.dcp)
34 test_seconds = hms_to_seconds(args.length)
35 while test_seconds > 0:
37 print("W %d" % (dcp_seconds * 1000))
38 test_seconds -= dcp_seconds
40 parser = argparse.ArgumentParser()
41 parser.add_argument('-d', '--dcp', help='DCP to make a script for', required=True)
42 parser.add_argument('-t', '--type', help='script type: seek - seek a lot, repeat - play back DCP over and over', required=True)
43 parser.add_argument('-l', '--length', help='approximate test length in H:M:S', required=True)
44 args = parser.parse_args()
46 for l in subprocess.run(['dcpinfo', args.dcp], capture_output=True).stdout.splitlines():
47 if l.startswith(b'Total:'):
49 dcp_seconds = (int(b[1]) * 60 + int(b[2])) * 60 + int(b[3])
50 if args.type == 'seek':
52 elif args.type == 'repeat':
55 print('Unknown type %s' % args.type, file=sys.stderr)