Mercurial > code > home > repos > light9
comparison bin/webcontrol @ 1859:f066d6e874db
2to3 with these fixers: all idioms set_literal
Ignore-this: cbd28518218c2f0ddce8c4f92d3b8b33
author | drewp@bigasterisk.com |
---|---|
date | Wed, 22 May 2019 00:08:22 +0000 |
parents | 7772cc48e016 |
children |
comparison
equal
deleted
inserted
replaced
1858:7772cc48e016 | 1859:f066d6e874db |
---|---|
4 computers and phones | 4 computers and phones |
5 | 5 |
6 todo: | 6 todo: |
7 disable buttons that don't make sense | 7 disable buttons that don't make sense |
8 """ | 8 """ |
9 import sys, xmlrpclib, traceback | 9 import sys, xmlrpc.client, traceback |
10 from twisted.internet import reactor | 10 from twisted.internet import reactor |
11 from twisted.python import log | 11 from twisted.python import log |
12 from twisted.python.util import sibpath | 12 from twisted.python.util import sibpath |
13 from twisted.internet.defer import inlineCallbacks, returnValue | 13 from twisted.internet.defer import inlineCallbacks, returnValue |
14 from twisted.web.client import getPage | 14 from twisted.web.client import getPage |
17 from rdflib import URIRef | 17 from rdflib import URIRef |
18 from louie.robustapply import robust_apply | 18 from louie.robustapply import robust_apply |
19 sys.path.append(".") | 19 sys.path.append(".") |
20 from light9 import showconfig, networking | 20 from light9 import showconfig, networking |
21 from light9.namespaces import L9 | 21 from light9.namespaces import L9 |
22 from urllib import urlencode | 22 from urllib.parse import urlencode |
23 | 23 |
24 | 24 |
25 # move to web lib | 25 # move to web lib |
26 def post(url, **args): | 26 def post(url, **args): |
27 return getPage(url, method='POST', postdata=urlencode(args)) | 27 return getPage(url, method='POST', postdata=urlencode(args)) |
29 | 29 |
30 class Commands(object): | 30 class Commands(object): |
31 | 31 |
32 @staticmethod | 32 @staticmethod |
33 def playSong(graph, songUri): | 33 def playSong(graph, songUri): |
34 s = xmlrpclib.ServerProxy(networking.musicPlayer.url) | 34 s = xmlrpc.client.ServerProxy(networking.musicPlayer.url) |
35 songPath = graph.value(URIRef(songUri), L9.showPath) | 35 songPath = graph.value(URIRef(songUri), L9.showPath) |
36 if songPath is None: | 36 if songPath is None: |
37 raise ValueError("unknown song %s" % songUri) | 37 raise ValueError("unknown song %s" % songUri) |
38 return s.playfile(songPath.encode('ascii')) | 38 return s.playfile(songPath.encode('ascii')) |
39 | 39 |
40 @staticmethod | 40 @staticmethod |
41 def stopMusic(graph): | 41 def stopMusic(graph): |
42 s = xmlrpclib.ServerProxy(networking.musicPlayer.url) | 42 s = xmlrpc.client.ServerProxy(networking.musicPlayer.url) |
43 return s.stop() | 43 return s.stop() |
44 | 44 |
45 @staticmethod | 45 @staticmethod |
46 def worklightsOn(graph): | 46 def worklightsOn(graph): |
47 return post(networking.keyboardComposer.path('fadesub'), | 47 return post(networking.keyboardComposer.path('fadesub'), |
88 @inlineCallbacks | 88 @inlineCallbacks |
89 def locateChild(self, ctx, segments): | 89 def locateChild(self, ctx, segments): |
90 try: | 90 try: |
91 func = getattr(Commands, segments[0]) | 91 func = getattr(Commands, segments[0]) |
92 req = inevow.IRequest(ctx) | 92 req = inevow.IRequest(ctx) |
93 simpleArgDict = dict((k, v[0]) for k, v in req.args.items()) | 93 simpleArgDict = dict((k, v[0]) for k, v in list(req.args.items())) |
94 try: | 94 try: |
95 ret = yield robust_apply(func, func, self.graph, | 95 ret = yield robust_apply(func, func, self.graph, |
96 **simpleArgDict) | 96 **simpleArgDict) |
97 except KeyboardInterrupt: | 97 except KeyboardInterrupt: |
98 raise | 98 raise |
99 except Exception, e: | 99 except Exception as e: |
100 print "Error on command %s" % segments[0] | 100 print("Error on command %s" % segments[0]) |
101 traceback.print_exc() | 101 traceback.print_exc() |
102 returnValue((url.here.up().add('status', | 102 returnValue((url.here.up().add('status', |
103 str(e)).add('error', | 103 str(e)).add('error', |
104 1), segments[1:])) | 104 1), segments[1:])) |
105 | 105 |