5 import win32serviceutil
11 class PyTivoService(win32serviceutil
.ServiceFramework
):
13 _svc_display_name_
= 'pyTivo'
15 def __init__(self
, args
):
16 win32serviceutil
.ServiceFramework
.__init
__(self
, args
)
17 self
.stop_event
= win32event
.CreateEvent(None, 0, 0, None)
25 p
= os
.path
.dirname(__file__
)
27 f
= open(os
.path
.join(p
, 'log.txt'), 'w')
31 port
= config
.getPort()
33 httpd
= httpserver
.TivoHTTPServer(('', int(port
)),
34 httpserver
.TivoHTTPHandler
)
36 for section
, settings
in config
.getShares():
37 httpd
.add_container(section
, settings
)
40 b
.add_service('TiVoMediaServer:%s/http' % port
)
42 if 'listen' in config
.getBeaconAddresses():
49 (rx
, tx
, er
) = select
.select((httpd
,), (), (), 5)
52 rc
= win32event
.WaitForSingleObject(self
.stop_event
, 5)
53 if rc
== win32event
.WAIT_OBJECT_0
:
58 win32event
.SetEvent(self
.stop_event
)
60 if __name__
== '__main__':
61 win32serviceutil
.HandleCommandLine(PyTivoService
)