6 import win32serviceutil
12 class PyTivoService(win32serviceutil
.ServiceFramework
):
14 _svc_display_name_
= 'pyTivo'
16 def __init__(self
, args
):
17 win32serviceutil
.ServiceFramework
.__init
__(self
, args
)
18 self
.stop_event
= win32event
.CreateEvent(None, 0, 0, None)
24 p
= os
.path
.dirname(__file__
)
26 f
= open(os
.path
.join(p
, 'log.txt'), 'w')
30 port
= config
.getPort()
32 httpd
= httpserver
.TivoHTTPServer(('', int(port
)),
33 httpserver
.TivoHTTPHandler
)
35 for section
, settings
in config
.getShares():
36 httpd
.add_container(section
, settings
)
39 b
.add_service('TiVoMediaServer:%s/http' % port
)
41 if 'listen' in config
.getBeaconAddresses():
48 (rx
, tx
, er
) = select
.select((httpd
,), (), (), 5)
51 rc
= win32event
.WaitForSingleObject(self
.stop_event
, 5)
52 if rc
== win32event
.WAIT_OBJECT_0
:
57 win32event
.SetEvent(self
.stop_event
)
59 if __name__
== '__main__':
60 win32serviceutil
.HandleCommandLine(PyTivoService
)