3 import beacon
, httpserver
, os
, sys
5 from debug
import print_conf
, fn_attr
6 from plugin
import GetPlugin
8 port
= config
.getPort()
10 httpd
= httpserver
.TivoHTTPServer(('', int(port
)), httpserver
.TivoHTTPHandler
)
12 for section
, settings
in config
.getShares():
13 httpd
.add_container(section
, settings
)
14 # Precaching of files: does a recursive list of base path
15 if settings
.get('precache', 'False').lower() == 'true':
16 plugin
= GetPlugin(settings
.get('type'))
17 if hasattr(plugin
, 'pre_cache'):
18 print 'Pre-caching the', section
, 'share.'
19 pre_cache_filter
= getattr(plugin
, 'pre_cache')
21 def build_recursive_list(path
):
22 for f
in os
.listdir(path
):
23 f
= os
.path
.join(path
, f
)
25 build_recursive_list(f
)
29 build_recursive_list(settings
.get('path'))
32 b
.add_service('TiVoMediaServer:' + str(port
) + '/http')
34 if 'listen' in config
.getBeaconAddresses():
37 print_conf(__name__
, fn_attr())
38 print 'pyTivo is ready.'
41 except KeyboardInterrupt: