9 if sys
.version_info
[0] != 2 or sys
.version_info
[1] < 4:
10 print ('ERROR: pyTivo requires Python >= 2.4, < 3.0.\n')
17 def exceptionLogger(*args
):
18 sys
.excepthook
= sys
.__excepthook
__
19 logging
.getLogger('pyTivo').error('Exception in pyTivo', exc_info
=args
)
23 path
= os
.path
.dirname(__file__
)
26 for root
, dirs
, files
in os
.walk(path
):
28 if name
.endswith('.py'):
29 tm
= os
.stat(os
.path
.join(root
, name
)).st_mtime
33 return time
.asctime(time
.localtime(lasttime
))
35 def setup(in_service
=False):
36 config
.init(sys
.argv
[1:])
38 sys
.excepthook
= exceptionLogger
40 port
= config
.getPort()
42 httpd
= httpserver
.TivoHTTPServer(('', int(port
)),
43 httpserver
.TivoHTTPHandler
)
45 logger
= logging
.getLogger('pyTivo')
46 logger
.info('Last modified: ' + last_date())
47 logger
.info('Python: ' + platform
.python_version())
48 logger
.info('System: ' + platform
.platform())
50 for section
, settings
in config
.getShares():
51 httpd
.add_container(section
, settings
)
54 b
.add_service('TiVoMediaServer:%s/http' % port
)
56 if 'listen' in config
.getBeaconAddresses():
60 httpd
.set_service_status(in_service
)
62 logger
.info('pyTivo is ready.')
68 except KeyboardInterrupt:
77 if __name__
== '__main__':