1 import beacon
, httpserver
, ConfigParser
2 import win32serviceutil
7 class PyTivoService(win32serviceutil
.ServiceFramework
):
9 _svc_display_name_
= 'pyTivo'
11 def __init__(self
, args
):
12 win32serviceutil
.ServiceFramework
.__init
__(self
, args
)
13 self
.stop_event
= win32event
.CreateEvent(None, 0, 0, None)
19 from Config
import config
21 p
= os
.path
.dirname(__file__
)
23 f
= open(os
.path
.join(p
, 'log.txt'), 'w')
28 port
= config
.get('Server', 'Port')
30 httpd
= httpserver
.TivoHTTPServer(('', int(port
)), httpserver
.TivoHTTPHandler
)
32 for section
in config
.sections():
33 if not section
== 'Server':
34 httpd
.add_container(section
, config
.get(section
, 'type'), config
.get(section
, 'path'))
37 b
.add_service('TiVoMediaServer:' + str(port
) + '/http')
42 (rx
, tx
, er
) = select
.select((httpd
,), (), (), 5)
45 rc
= win32event
.WaitForSingleObject(self
.stop_event
, 5)
46 if rc
== win32event
.WAIT_OBJECT_0
:
51 win32event
.SetEvent(self
.stop_event
)
53 if __name__
== '__main__':
54 win32serviceutil
.HandleCommandLine(PyTivoService
)