7 import beacon
, httpserver
, os
, sys
9 from plugin
import GetPlugin
13 p
= os
.path
.dirname(__file__
)
15 if config
.config
.has_section('loggers') and\
16 config
.config
.has_section('handlers') and\
17 config
.config
.has_section('formatters'):
19 logging
.config
.fileConfig(config
.config_files
)
21 elif config
.getDebug(0):
22 logging
.basicConfig(level
=logging
.DEBUG
)
24 logging
.basicConfig(level
=logging
.INFO
)
28 port
= config
.getPort()
30 httpd
= httpserver
.TivoHTTPServer(('', int(port
)), httpserver
.TivoHTTPHandler
)
32 for section
, settings
in config
.getShares():
33 httpd
.add_container(section
, settings
)
34 # Precaching of files: does a recursive list of base path
35 if settings
.get('precache', 'False').lower() == 'true':
36 plugin
= GetPlugin(settings
.get('type'))
37 if hasattr(plugin
, 'pre_cache'):
38 print 'Pre-caching the', section
, 'share.'
39 pre_cache_filter
= getattr(plugin
, 'pre_cache')
41 def build_recursive_list(path
):
43 for f
in os
.listdir(path
):
44 f
= os
.path
.join(path
, f
)
46 build_recursive_list(f
)
52 build_recursive_list(settings
.get('path'))
55 b
.add_service('TiVoMediaServer:' + str(port
) + '/http')
57 if 'listen' in config
.getBeaconAddresses():
60 logging
.getLogger('pyTivo').info('pyTivo is ready.')
64 except KeyboardInterrupt: