def importXml(cls, xmlcontent): """ @type xmlcontent: string @rtype: L{Flow} """ flow = Flow() dom = parseString(xmlcontent) import_plugins(florun.plugins_dirs, globals()) for xmlnode in dom.getElementsByTagName('node'): nodeid = xmlnode.getAttribute('id') classname = xmlnode.getAttribute('type') logger.debug( _(u"XML node type %(classname)s with id '%(nodeid)s'") % locals()) # Dynamic instanciation of node type try: classobj = eval(classname) except: raise FlowParsingError( _(u"Unknown node type '%s'") % classname) node = classobj(flow=flow, id=nodeid) # Load graphical attributes for prop in xmlnode.getElementsByTagName('graphproperty'): name = prop.getAttribute('name') value = atoi(prop.getAttribute('value')) logger.debug(_(u"XML node property : %s = %s") % (name, value)) node.graphicalprops[name] = value flow.addNode(node) # Once all nodes have been loaded, load links : for xmlnode in dom.getElementsByTagName('node'): nodeid = xmlnode.getAttribute('id') node = flow.findNode(nodeid) for xmlinterface in xmlnode.getElementsByTagName('interface'): name = xmlinterface.getAttribute('name') src = node.findInterface(name) src.slot = True if src.isInput() and src.isValue(): src.slot = xmlinterface.getAttribute( 'slot').lower() == 'true' if not src.slot: src.value = xmlinterface.getAttribute('value') for xmlsuccessor in xmlinterface.getElementsByTagName( 'successor'): dnodeid = xmlsuccessor.getAttribute('node') dnode = flow.findNode(dnodeid) # Find interface on destination node dname = xmlsuccessor.getAttribute('interface') dest = dnode.findInterface(dname) dest.slot = True src.addSuccessor(dest) flow.sortNodesByIncidence() return flow
def importXml(cls, xmlcontent): """ @type xmlcontent: string @rtype: L{Flow} """ flow = Flow() dom = parseString(xmlcontent) import_plugins(florun.plugins_dirs, globals()) for xmlnode in dom.getElementsByTagName('node'): nodeid = xmlnode.getAttribute('id') classname = xmlnode.getAttribute('type') logger.debug(_(u"XML node type %(classname)s with id '%(nodeid)s'") % locals()) # Dynamic instanciation of node type try: classobj = eval(classname) except: raise FlowParsingError(_(u"Unknown node type '%s'") % classname) node = classobj(flow=flow, id=nodeid) # Load graphical attributes for prop in xmlnode.getElementsByTagName('graphproperty'): name = prop.getAttribute('name') value = atoi(prop.getAttribute('value')) logger.debug(_(u"XML node property : %s = %s") % (name, value)) node.graphicalprops[name] = value flow.addNode(node) # Once all nodes have been loaded, load links : for xmlnode in dom.getElementsByTagName('node'): nodeid = xmlnode.getAttribute('id') node = flow.findNode(nodeid) for xmlinterface in xmlnode.getElementsByTagName('interface'): name = xmlinterface.getAttribute('name') src = node.findInterface(name) src.slot = True if src.isInput() and src.isValue(): src.slot = xmlinterface.getAttribute('slot').lower() == 'true' if not src.slot: src.value = xmlinterface.getAttribute('value') for xmlsuccessor in xmlinterface.getElementsByTagName('successor'): dnodeid = xmlsuccessor.getAttribute('node') dnode = flow.findNode(dnodeid) # Find interface on destination node dname = xmlsuccessor.getAttribute('interface') dest = dnode.findInterface(dname) dest.slot = True src.addSuccessor(dest) flow.sortNodesByIncidence() return flow
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. import utils import sys import getpass import os import subprocess import os.path from ansible.color import stringc dirname = os.path.dirname(__file__) callbacks = utils.import_plugins(os.path.join(dirname, 'callback_plugins')) callbacks = [ c.CallbackModule() for c in callbacks.values() ] cowsay = None if os.path.exists("/usr/bin/cowsay"): cowsay = "/usr/bin/cowsay" elif os.path.exists("/usr/games/cowsay"): cowsay = "/usr/games/cowsay" def call_callback_module(method_name, *args, **kwargs): for callback_plugin in callbacks: methods = [ getattr(callback_plugin, method_name, None), getattr(callback_plugin, 'on_any', None) ]
file_cfg = args.c if args.c else os.path.dirname(__file__) + '/config.json' dir_tmpl = args.t if args.t else os.path.dirname(__file__) + '/templates' file_out = args.o if args.o else None # # open configuration file config = json.loads( utils.getfile(file_cfg) ) # # overwrite debug mode if args.debug: config['debug'] = True # # import plugins plugins = utils.import_plugins() # # run plugins test() function if debug mode if config['debug']: utils.debug('Executing test() from plugins:') for p in plugins.values(): # check if test function exists if hasattr(p,'test'): utils.debug('- '+p.__name__+'.test() >> '+p.test()) # # HTML header if os.path.isfile(dir_tmpl+'/_header_.html'): html = utils.getfile(dir_tmpl+'/_header_.html')