1 from twisted.web2 import http, http_headers, resource, responsecode
2 from AutoTimer import AutoTimer
5 # pretty basic resource which is just present to have a way to start a
6 # forced run through the webif
7 class AutoTimerResource(resource.Resource):
9 resource.Resource.__init__(self)
11 def render(self, req):
12 from plugin import autotimer
17 autotimer = AutoTimer()
20 if req.args.has_key("parse"):
21 ret = autotimer.parseEPG()
22 output = _("Found a total of %d matching Events.\n%d Timer were added and %d modified.") % (ret[0], ret[1], ret[2])
25 output = "unknown command"
31 result = """<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n
33 <e2state>%s</e2state>\n
34 <e2statetext>%s</e2statetext>\n
36 """ % ('true' if res else 'false', output)
38 XML_HEADER = {'Content-type': http_headers.MimeType('application', 'xhtml+xml', (('charset', 'UTF-8'),))}
39 return http.Response(responsecode.OK, XML_HEADER, stream = result)