Mercurial > code > home > repos > light9
annotate bin/staticclient @ 2357:ccd04278e357
metrics cleanup
author | drewp@bigasterisk.com |
---|---|
date | Sat, 03 Jun 2023 17:15:40 -0700 |
parents | f066d6e874db |
children |
rev | line source |
---|---|
1176 | 1 #!bin/python |
2 """ | |
3 push a dmx level forever | |
4 """ | |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
5 |
1176 | 6 import time, logging |
7 from optparse import OptionParser | |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
8 import logging, urllib.request, urllib.parse, urllib.error |
1176 | 9 from twisted.internet import reactor, tksupport, task |
10 from rdflib import URIRef, RDF, RDFS, Literal | |
11 | |
12 from run_local import log | |
13 log.setLevel(logging.DEBUG) | |
14 | |
15 from light9 import dmxclient, showconfig, networking | |
16 | |
17 if __name__ == "__main__": | |
18 parser = OptionParser(usage="%prog") | |
1858 | 19 parser.add_option('--chan', help='channel number, starts at 1', |
20 type=int) #todo: or name or uri | |
1176 | 21 parser.add_option('--level', help='0..1', type=float) |
22 parser.add_option('-v', action='store_true', help="log debug level") | |
23 | |
24 opts, args = parser.parse_args() | |
25 | |
26 log.setLevel(logging.DEBUG if opts.v else logging.INFO) | |
27 | |
28 levels = [0] * (opts.chan - 1) + [opts.level] | |
29 log.info('staticclient will write this forever: %r', levels) | |
1858 | 30 |
1176 | 31 def write(): |
32 log.debug('writing %r', levels) | |
33 dmxclient.outputlevels(levels, twisted=1) | |
1858 | 34 |
1176 | 35 log.info('looping...') |
36 task.LoopingCall(write).start(1) | |
37 reactor.run() |