[svn r944] Now add/cancel a schedule recording while livetv is running is finnaly working fine.
3 __author__ = "Gustavo Sverzut Barbieri / Artur Duque de Souza"
4 __author_email__ = "barbieri@gmail.com / artur.souza@indt.org.br"
15 import lib.utils as utils
19 from request_handler import RequestHandler
21 __all__ = ("Server", "serve_forever", "load_plugins_transcoders")
23 class Server(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer):
24 log = logging.getLogger("gms.server")
28 _lock = threading.RLock()
30 def serve_forever(self):
31 self.log.info("GMyth-Streamer serving HTTP on %s:%s" %
32 self.socket.getsockname())
36 except KeyboardInterrupt, e:
39 self.log.debug("Stopping all remaining transcoders...")
40 self.stop_transcoders()
41 self.log.debug("Transcoders stopped!")
45 def get_request(self):
47 old = skt.gettimeout()
54 except socket.timeout, e:
56 raise socket.error("Not running")
60 def server_close(self):
62 self.stop_transcoders()
64 BaseHTTPServer.HTTPServer.server_close(self)
68 def stop_transcoders(self):
70 for transcoder, request in self._transcoders.iteritems():
71 self.log.info("Stop transcoder: %s, client=%s" %
72 (transcoder, request.client_address))
78 def get_transcoders(self):
81 return self._transcoders.items()
87 def add_transcoders(self, request, transcoder):
90 self._transcoders[transcoder] = request
96 def del_transcoders(self, request, transcoder):
99 del self._transcoders[transcoder]
107 def serve_forever(host="0.0.0.0", port=40000):
109 RequestHandler.protocol_version = "HTTP/1.0"
110 httpd = Server(addr, RequestHandler)
111 httpd.serve_forever()
115 def load_plugins_transcoders(directory):
116 RequestHandler.load_plugins_transcoders(directory)
117 # load_plugins_transcoders()