7 if sys
.version_info
[0] != 2 or sys
.version_info
[1] < 4:
8 print ('ERROR: pyTivo requires Python >= 2.4, < 3.0.\n')
14 from plugin
import GetPlugin
16 def exceptionLogger(*args
):
17 sys
.excepthook
= sys
.__excepthook
__
18 logging
.getLogger('pyTivo').error('Exception in pyTivo', exc_info
=args
)
20 config
.init(sys
.argv
[1:])
22 sys
.excepthook
= exceptionLogger
24 port
= config
.getPort()
26 httpd
= httpserver
.TivoHTTPServer(('', int(port
)), httpserver
.TivoHTTPHandler
)
28 logger
= logging
.getLogger('pyTivo')
30 for section
, settings
in config
.getShares():
31 httpd
.add_container(section
, settings
)
32 # Precaching of files: does a recursive list of base path
33 if settings
.get('precache', 'False').lower() == 'true':
34 plugin
= GetPlugin(settings
.get('type'))
35 if hasattr(plugin
, 'pre_cache'):
36 logger
.info('Pre-caching the ' + section
+ ' share.')
37 pre_cache_filter
= getattr(plugin
, 'pre_cache')
39 def build_recursive_list(path
):
41 for f
in os
.listdir(path
):
42 f
= os
.path
.join(path
, f
)
44 build_recursive_list(f
)
50 build_recursive_list(settings
.get('path'))
53 b
.add_service('TiVoMediaServer:%s/http' % port
)
55 if 'listen' in config
.getBeaconAddresses():
58 logger
.info('pyTivo is ready.')
63 except KeyboardInterrupt: