9 if sys
.version_info
[0] != 2 or sys
.version_info
[1] < 5:
10 print ('ERROR: pyTivo requires Python >= 2.5, < 3.0.\n')
15 ssl
._create
_default
_https
_context
= ssl
._create
_unverified
_context
23 def exceptionLogger(*args
):
24 sys
.excepthook
= sys
.__excepthook
__
25 logging
.getLogger('pyTivo').error('Exception in pyTivo', exc_info
=args
)
29 path
= os
.path
.dirname(__file__
)
32 for root
, dirs
, files
in os
.walk(path
):
34 if name
.endswith('.py'):
35 tm
= os
.path
.getmtime(os
.path
.join(root
, name
))
39 return time
.asctime(time
.localtime(lasttime
))
41 def setup(in_service
=False):
42 config
.init(sys
.argv
[1:])
44 sys
.excepthook
= exceptionLogger
46 port
= config
.getPort()
48 httpd
= httpserver
.TivoHTTPServer(('', int(port
)),
49 httpserver
.TivoHTTPHandler
)
51 logger
= logging
.getLogger('pyTivo')
52 logger
.info('Last modified: ' + last_date())
53 logger
.info('Python: ' + platform
.python_version())
54 logger
.info('System: ' + platform
.platform())
56 for section
, settings
in config
.getShares():
57 httpd
.add_container(section
, settings
)
60 b
.add_service('TiVoMediaServer:%s/http' % port
)
62 if 'listen' in config
.getBeaconAddresses():
66 httpd
.set_service_status(in_service
)
68 logger
.info('pyTivo is ready.')
74 except KeyboardInterrupt:
83 if __name__
== '__main__':