remove debug
[enigma2-plugins.git] / webinterface / src / WebChilds / Toplevel.py
1 from twisted.web import resource, static
2 from twisted.python import util
3
4 from Components.config import config
5
6 from Plugins.Extensions.WebInterface import __file__ 
7 from Screenpage import ScreenPage
8 from FileStreamer import FileStreamer
9 from Screengrab import GrabResource
10 from IPKG import IPKGResource
11 from PlayService import ServiceplayerResource
12 #from Uploader import UploadResource
13 from ServiceListSave import ServiceList
14 from RedirecToCurrentStream import RedirecToCurrentStreamResource
15
16 from External.__init__ import importExternalModules
17 externalChildren = []
18
19 def addExternalChild(child):
20         externalChildren.append(child)
21
22 def getToplevel(session):
23         root = static.File(util.sibpath(__file__, "web-data/tpl/default"))
24         
25         root.putChild("web", ScreenPage(session, util.sibpath(__file__, "web"), True) ) # "/web/*"
26         root.putChild("web-data", static.File(util.sibpath(__file__, "web-data")))
27         root.putChild("file", FileStreamer())
28         root.putChild("grab", GrabResource())
29         root.putChild("ipkg", IPKGResource())
30         root.putChild("play", ServiceplayerResource(session))
31         root.putChild("wap", RedirectorResource("/mobile/"))
32         root.putChild("mobile", ScreenPage(session, util.sibpath(__file__, "mobile"), True) )
33         #root.putChild("upload", UploadResource())
34         root.putChild("servicelist", ServiceList(session))
35         root.putChild("streamcurrent", RedirecToCurrentStreamResource(session))
36                 
37         if config.plugins.Webinterface.includemedia.value is True:
38                 root.putChild("media", static.File("/media"))
39                 root.putChild("hdd", static.File("/media/hdd"))
40                 
41         
42         importExternalModules()
43
44         for child in externalChildren:
45                 if len(child) == 2:
46                         root.putChild(child[0], child[1])
47         
48         return root
49                 
50 class RedirectorResource(resource.Resource):
51         """
52                 this class can be used to redirect a request to a specified uri
53         """
54         def __init__(self, uri):
55                 self.uri = uri
56                 resource.Resource.__init__(self)
57         
58         def render(self, request):
59                 request.redirect(self.uri)
60                 request.finish()
61