1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import os
23
24 from twisted.web.resource import Resource
25 from twisted.web.static import Data, File
26
27 from flumotion.common import log
28 from flumotion.common.errors import ComponentStartError
29 from flumotion.component.misc.httpserver.httpserver import HTTPFileStreamer
30 from flumotion.component.plugs.base import ComponentPlug
31 from flumotion.component.plugs.cortado.cortado_location import \
32 getCortadoFilename
33 from flumotion.configure import configure
34
35 __version__ = "$Rev: 8019 $"
36
37
39 if value:
40 return 'true'
41 return 'false'
42
43
45 """I generate the directory used to serve a cortado applet
46 It contains::
47 - a html file, usually called index.html.
48 - cortado.jar - cortado java applet
49 """
50
51 - def __init__(self, mount_point, properties, filename):
52 Resource.__init__(self)
53
54 index_name = properties.get('index', 'index.html')
55
56 root = mount_point
57 if not root.endswith("/"):
58 root += "/"
59 if index_name != 'index.html':
60 root = None
61 self._mount_point_root = root
62 self._properties = properties
63 self._index_content = self._get_index_content()
64 self._index_name = index_name
65 self._cortado_filename = filename
66 self._addChildren()
67
69 self.putChild("cortado.jar",
70 File(self._cortado_filename,
71 'application/x-java-archive'))
72
73 self.putChild(self._index_name,
74 self._index_content)
75 self.putChild('', self._index_content)
76
83
85 html_template = self._get_template_filename()
86 ns = {}
87 ns['has-audio'] = _htmlbool(self._properties['has-audio'])
88 ns['has-video'] = _htmlbool(self._properties['has-video'])
89 for attribute in ['codebase',
90 'width',
91 'height',
92 'stream-url',
93 'buffer-size']:
94 ns[attribute] = self._properties[attribute]
95
96 data = open(html_template, 'r').read()
97 content = data % ns
98 return Data(content, 'text/html')
99
100
102 """I am a component plug for a http-server which plugs in a
103 http resource containing a cortado java applet.
104 """
105
106 - def start(self, component):
124
125
145
146 if __name__ == "__main__":
147 test()
148