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 p
= os
.path
.dirname(__file__
)
21 f
= open(os
.path
.join(p
, 'log.txt'), 'w')
26 config
= ConfigParser
.ConfigParser()
27 config
.read( os
.path
.join(p
, 'pyTivo.conf') )
29 port
= config
.get('Server', 'Port')
31 httpd
= httpserver
.TivoHTTPServer(('', int(port
)), httpserver
.TivoHTTPHandler
)
33 for section
in config
.sections():
34 if not section
== 'Server':
35 httpd
.add_container(section
, config
.get(section
, 'type'), config
.get(section
, 'path'))
38 b
.add_service('TiVoMediaServer:' + str(port
) + '/http')
43 (rx
, tx
, er
) = select
.select((httpd
,), (), (), 5)
46 rc
= win32event
.WaitForSingleObject(self
.stop_event
, 5)
47 if rc
== win32event
.WAIT_OBJECT_0
:
51 win32event
.SetEvent(self
.stop_event
)
53 if __name__
== '__main__':
54 win32serviceutil
.HandleCommandLine(PyTivoService
)