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')
32 port
= config
.getPort()
34 httpd
= httpserver
.TivoHTTPServer(('', int(port
)),
35 httpserver
.TivoHTTPHandler
)
37 for section
, settings
in config
.getShares():
38 httpd
.add_container(section
, settings
)
41 b
.add_service('TiVoMediaServer:%s/http' % port
)
43 if 'listen' in config
.getBeaconAddresses():
50 (rx
, tx
, er
) = select
.select((httpd
,), (), (), 5)
53 rc
= win32event
.WaitForSingleObject(self
.stop_event
, 5)
54 if rc
== win32event
.WAIT_OBJECT_0
:
59 win32event
.SetEvent(self
.stop_event
)
61 if __name__
== '__main__':
62 win32serviceutil
.HandleCommandLine(PyTivoService
)