10 from plugin
import GetPlugin
12 def exceptionLogger(*args
):
13 sys
.excepthook
= sys
.__excepthook
__
14 logging
.getLogger('pyTivo').error('Exception in pyTivo', exc_info
=args
)
16 config
.init(sys
.argv
[1:])
18 sys
.excepthook
= exceptionLogger
20 port
= config
.getPort()
22 httpd
= httpserver
.TivoHTTPServer(('', int(port
)), httpserver
.TivoHTTPHandler
)
24 logger
= logging
.getLogger('pyTivo')
26 for section
, settings
in config
.getShares():
27 httpd
.add_container(section
, settings
)
28 # Precaching of files: does a recursive list of base path
29 if settings
.get('precache', 'False').lower() == 'true':
30 plugin
= GetPlugin(settings
.get('type'))
31 if hasattr(plugin
, 'pre_cache'):
32 logger
.info('Pre-caching the ' + section
+ ' share.')
33 pre_cache_filter
= getattr(plugin
, 'pre_cache')
35 def build_recursive_list(path
):
37 for f
in os
.listdir(path
):
38 f
= os
.path
.join(path
, f
)
40 build_recursive_list(f
)
46 build_recursive_list(settings
.get('path'))
49 b
.add_service('TiVoMediaServer:%s/http' % port
)
51 if 'listen' in config
.getBeaconAddresses():
54 logger
.info('pyTivo is ready.')
59 except KeyboardInterrupt: