9 if sys
.version_info
[0] != 2 or sys
.version_info
[1] < 4:
10 print ('ERROR: pyTivo requires Python >= 2.4, < 3.0.\n')
16 from plugin
import GetPlugin
18 def exceptionLogger(*args
):
19 sys
.excepthook
= sys
.__excepthook
__
20 logging
.getLogger('pyTivo').error('Exception in pyTivo', exc_info
=args
)
24 path
= os
.path
.dirname(__file__
)
27 for root
, dirs
, files
in os
.walk(path
):
29 if name
.endswith('.py'):
30 tm
= os
.stat(os
.path
.join(root
, name
)).st_mtime
34 return time
.asctime(time
.localtime(lasttime
))
36 def setup(in_service
=False):
37 config
.init(sys
.argv
[1:])
39 sys
.excepthook
= exceptionLogger
41 port
= config
.getPort()
43 httpd
= httpserver
.TivoHTTPServer(('', int(port
)),
44 httpserver
.TivoHTTPHandler
)
46 logger
= logging
.getLogger('pyTivo')
47 logger
.info('Last modified: ' + last_date())
48 logger
.info('Python: ' + platform
.python_version())
49 logger
.info('System: ' + platform
.platform())
51 for section
, settings
in config
.getShares():
52 httpd
.add_container(section
, settings
)
55 b
.add_service('TiVoMediaServer:%s/http' % port
)
57 if 'listen' in config
.getBeaconAddresses():
61 httpd
.set_service_status(in_service
)
63 logger
.info('pyTivo is ready.')
69 except KeyboardInterrupt:
78 if __name__
== '__main__':