7 import beacon
, httpserver
, os
, sys
9 from plugin
import GetPlugin
12 if (config
.config
.has_section('loggers') and
13 config
.config
.has_section('handlers') and
14 config
.config
.has_section('formatters')):
16 logging
.config
.fileConfig(config
.config_files
)
18 elif config
.getDebug():
19 logging
.basicConfig(level
=logging
.DEBUG
)
21 logging
.basicConfig(level
=logging
.INFO
)
25 port
= config
.getPort()
27 httpd
= httpserver
.TivoHTTPServer(('', int(port
)), httpserver
.TivoHTTPHandler
)
29 for section
, settings
in config
.getShares():
30 httpd
.add_container(section
, settings
)
31 # Precaching of files: does a recursive list of base path
32 if settings
.get('precache', 'False').lower() == 'true':
33 plugin
= GetPlugin(settings
.get('type'))
34 if hasattr(plugin
, 'pre_cache'):
35 print 'Pre-caching the', section
, 'share.'
36 pre_cache_filter
= getattr(plugin
, 'pre_cache')
38 def build_recursive_list(path
):
40 for f
in os
.listdir(path
):
41 f
= os
.path
.join(path
, f
)
43 build_recursive_list(f
)
49 build_recursive_list(settings
.get('path'))
52 b
.add_service('TiVoMediaServer:' + str(port
) + '/http')
54 if 'listen' in config
.getBeaconAddresses():
57 logging
.getLogger('pyTivo').info('pyTivo is ready.')
62 except KeyboardInterrupt: