Trees | Indices | Help |
---|
|
1 # -*- Mode: Python; test-case-name: flumotion.test.test_wizard -*- 2 # vi:si:et:sw=4:sts=4:ts=4 3 # 4 # Flumotion - a streaming media server 5 # Copyright (C) 2004,2005,2006,2007,2008 Fluendo, S.L. (www.fluendo.com). 6 # All rights reserved. 7 8 # This file may be distributed and/or modified under the terms of 9 # the GNU General Public License version 2 as published by 10 # the Free Software Foundation. 11 # This file is distributed without any warranty; without even the implied 12 # warranty of merchantability or fitness for a particular purpose. 13 # See "LICENSE.GPL" in the source distribution for more information. 14 15 # Licensees having purchased or holding a valid Flumotion Advanced 16 # Streaming Server license may use this file in accordance with the 17 # Flumotion Advanced Streaming Server Commercial License Agreement. 18 # See "LICENSE.Flumotion" in the source distribution for more information. 19 20 # Headers in this file shall remain intact. 21 22 import operator 23 from cStringIO import StringIO 24 from xml.sax.saxutils import quoteattr 25 26 from flumotion.common.xmlwriter import cmpComponentType, XMLWriter 27 from flumotion.configure import configure 28 29 __version__ = "$Rev: 6246 $" 30 3133 """I am responsible for writing the state of a flow created by the 34 configuration assistant into XML. 35 I will try my best write pretty XML which can be editable by humans at a 36 later point. 37 """ 3813540 """ 41 @param flowName: name of the flow 42 @param flowComponents: components to be included in the flow 43 @param atmosphereComponents: components to be included 44 in the atmosphere 45 """ 46 super(ConfigurationWriter, self).__init__() 47 self._flowName = flowName 48 self._flowComponents = flowComponents 49 self._atmosphereComponents = atmosphereComponents 50 self._writePlanet()5153 self.pushTag('planet') 54 self._writeAtmosphere(self._atmosphereComponents) 55 self._writeFlow(self._flowName, self._flowComponents) 56 self.popTag()5759 if not components: 60 return 61 self.pushTag('atmosphere') 62 self._writeComponents(components) 63 self.popTag()6466 if not components: 67 return 68 self.pushTag('flow', [('name', flowName)]) 69 self._writeComponents(components) 70 self.popTag()7173 components = sorted(components, 74 cmp=cmpComponentType, 75 key=operator.attrgetter('componentType')) 76 for component in components: 77 self._writeComponent(component)7880 # Do not write components which already exists in the flow, 81 # This is used to create configuration snippets sent to the 82 # asssistant which links to existing components 83 if component.exists: 84 return 85 86 # FIXME: when the assistant can be split among projects, "project" 87 # and "version" should be taken from the relevant project 88 attrs = [('name', component.name), 89 ('type', component.componentType), 90 ('project', configure.PACKAGE), 91 ('worker', component.worker), 92 ('version', configure.version)] 93 self.pushTag('component', attrs) 94 self._writeEaters(component.getEaters()) 95 self._writeProperties(component.getProperties()) 96 self._writeComponentPlugs(component.plugs) 97 self.popTag()98100 eaters = list(eaters) 101 if not eaters: 102 return 103 self.pushTag('eater', [('name', "default")]) 104 for sourceName in eaters: 105 self.writeTag('feed', data=sourceName) 106 self.popTag()107109 if not properties: 110 return 111 self.writeLine() 112 propertyNames = properties.keys() 113 propertyNames.sort() 114 for name in propertyNames: 115 value = properties[name] 116 # Fractions, perhaps we should do type introspection here? 117 if isinstance(value, tuple): 118 assert len(value) == 2 119 value = '%d/%d' % value 120 self.writeTag('property', [('name', name)], value)121123 if not plugs: 124 return 125 self.writeLine() 126 self.pushTag('plugs') 127 for plug in plugs: 128 self._writeComponentPlug(plug) 129 self.popTag()130132 self.pushTag('plug', [('type', plug.plugType)]) 133 self._writeProperties(plug.getProperties()) 134 self.popTag()
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu May 5 05:30:33 2011 | http://epydoc.sourceforge.net |