Ejemplo n.º 1
0
def initialize():
    def parse_error_if_not_equal(s, expected):
        if s != expected:
            err = "Parse error on version line. Was expecting '%s', got '%s'"
            raise RuntimeError(err % (s, expected))

    reg = vistrails.core.modules.module_registry.get_module_registry()

    reg.add_module(ImageMagick, abstract=True)

    reg.add_module(Convert)
    reg.add_input_port(Convert, "input", (basic.File, 'the input file'))
    reg.add_input_port(
        Convert, "inputFormat",
        (basic.String, 'coerce interpretation of file to this format'))
    reg.add_output_port(Convert, "output", (basic.File, 'the output file'))
    reg.add_input_port(Convert, "outputFormat",
                       (basic.String, 'Force output to be of this format'))

    for (name, opt, doc_string) in no_param_options:
        m = new_module(Convert,
                       name,
                       no_param_options_method_dict(opt),
                       docstring=doc_string)
        reg.add_module(m)

    for (name, opt, paramName, paramComment) in float_param_options:
        m = new_module(Convert, name,
                       float_param_options_method_dict(opt, paramName))
        reg.add_module(m)
        reg.add_input_port(m, paramName, (basic.Float, paramComment))

    reg.add_module(GaussianBlur)
    reg.add_input_port(GaussianBlur, "radiusSigma", [(basic.Float, 'radius'),
                                                     (basic.Float, 'sigma')])

    reg.add_module(Scale)
    reg.add_input_port(Scale, "geometry",
                       (basic.String, 'ImageMagick geometry'))
    reg.add_input_port(Scale, "width",
                       (basic.String, 'width of the geometry for operation'))
    reg.add_input_port(Scale, "height",
                       (basic.String, 'height of the geometry for operation'))

    reg.add_module(CombineRGBA)
    reg.add_input_port(CombineRGBA, "r", basic.File)
    reg.add_input_port(CombineRGBA, "g", basic.File)
    reg.add_input_port(CombineRGBA, "b", basic.File)
    reg.add_input_port(CombineRGBA, "a", basic.File, optional=True)
    reg.add_input_port(CombineRGBA, "outputFormat", basic.String)
    reg.add_output_port(CombineRGBA, "output", basic.File)
Ejemplo n.º 2
0
def new_constant(name, namespace, identifier, 
                 version, widget_type=StandardConstantWidget):
    """new_constant(name: str, namespace: str,widget_type: QWidget type) -> Module
    
    new_constant dynamically creates a new Module derived from Constant
    with a widget type."""
    reg = vistrails.core.modules.module_registry.get_module_registry()
    
    def __init__(self):
        Constant.__init__(self)

    @staticmethod
    def get_widget_class():
        return widget_type

    @staticmethod
    def conversion(self): return self
    
    m = new_module(Constant, name, {'__init__': __init__,
                                    'get_widget_class': get_widget_class,
                                    'translate_to_python': conversion})
    m.name = name
    m.isEnumeration = True
    reg.add_module(m,namespace=namespace,package=identifier,
                   package_version=version)
    return m
Ejemplo n.º 3
0
    def createPackage(self):
        reg = vistrails.core.modules.module_registry.get_module_registry()
        if self.signature in reg.packages:
            reg.remove_package(reg.packages[self.signature])

        # create a document hash integer from the cached sax tree
        # "name" is what suds use as the cache key
        name = '%s-%s' % (abs(hash(self.address)), "wsdl")
        wsdl = package_cache.get(name)
        if not wsdl:
            debug.critical("File not found in SUDS cache: '%s'" % name)
            self.wsdlHash = '0'
            return
        self.wsdlHash = str(int(hashlib.md5(str(wsdl.root)).hexdigest(), 16))

        package_id = reg.idScope.getNewId(Package.vtType)
        package = Package(id=package_id,
                          load_configuration=False,
                          name="SUDS#" + self.address,
                          identifier=self.signature,
                          version=self.wsdlHash,
                          )
        suds_package = reg.get_package_by_name(identifier)
        package._module = suds_package.module
        package._init_module = suds_package.init_module
        
        self.package = package
        reg.add_package(package)
        reg.signals.emit_new_package(self.signature)

        self.module = new_module(Module, str(self.signature))
        reg.add_module(self.module, **{'package':self.signature,
                                       'package_version':self.wsdlHash,
                                       'abstract':True})
Ejemplo n.º 4
0
    def createFailedPackage(self):
        """ Failed package is created so that the user can remove
        it manually using package submenu """
        pm = get_package_manager()
        if pm.has_package(self.signature):
            # do nothing
            return
        reg = vistrails.core.modules.module_registry.get_module_registry()

        # create a document hash integer from the cached sax tree
        # "name" is what suds use as the cache key
        name = '%s-%s' % (abs(hash(self.address)), "wsdl")
        self.wsdlHash = '0'

        package_id = reg.idScope.getNewId(Package.vtType)
        package = Package(id=package_id,
                          load_configuration=False,
                          name="SUDS#" + self.address,
                          identifier=self.signature,
                          version=self.wsdlHash,
                          )
        suds_package = reg.get_package_by_name(identifier)
        package._module = suds_package.module
        package._init_module = suds_package.init_module
        self.package = package
        reg.add_package(package)
        reg.signals.emit_new_package(self.signature)
        self.module = new_module(Module, str(self.signature))
        reg.add_module(self.module, **{'package':self.signature,
                                       'package_version':self.wsdlHash,
                                       'abstract':True})
        self.service = -1
Ejemplo n.º 5
0
def initialize(namemodule,namespace,identifier, version):
    reg = get_module_registry()

    enumerationConstant = new_module(Constant, namemodule, {})
    enumerationConstant.name = namemodule
    enumerationConstant.isEnumeration = True
    reg.add_module(enumerationConstant, namespace=namespace, package=identifier,
                   package_version=version)

    return enumerationConstant
Ejemplo n.º 6
0
def initialize():
    def parse_error_if_not_equal(s, expected):
        if s != expected:
            err = "Parse error on version line. Was expecting '%s', got '%s'"
            raise RuntimeError(err % (s, expected))

    reg = vistrails.core.modules.module_registry.get_module_registry()

    reg.add_module(ImageMagick, abstract=True)

    reg.add_module(Convert)
    reg.add_input_port(Convert, "input", (basic.File, 'the input file'))
    reg.add_input_port(Convert, "inputFormat", (basic.String, 'coerce interpretation of file to this format'))
    reg.add_output_port(Convert, "output", (basic.File, 'the output file'))
    reg.add_input_port(Convert, "outputFormat", (basic.String, 'Force output to be of this format'))

    for (name, opt, doc_string) in no_param_options:
        m = new_module(Convert, name, no_param_options_method_dict(opt),
                      docstring=doc_string)
        reg.add_module(m)

    for (name, opt, paramName, paramComment) in float_param_options:
        m = new_module(Convert, name, float_param_options_method_dict(opt, paramName))
        reg.add_module(m)
        reg.add_input_port(m, paramName, (basic.Float, paramComment))

    reg.add_module(GaussianBlur)
    reg.add_input_port(GaussianBlur, "radiusSigma", [(basic.Float, 'radius'), (basic.Float, 'sigma')])

    reg.add_module(Scale)
    reg.add_input_port(Scale, "geometry", (basic.String, 'ImageMagick geometry'))
    reg.add_input_port(Scale, "width", (basic.String, 'width of the geometry for operation'))
    reg.add_input_port(Scale, "height", (basic.String, 'height of the geometry for operation'))

    reg.add_module(CombineRGBA)
    reg.add_input_port(CombineRGBA, "r", basic.File)
    reg.add_input_port(CombineRGBA, "g", basic.File)
    reg.add_input_port(CombineRGBA, "b", basic.File)
    reg.add_input_port(CombineRGBA, "a", basic.File, optional=True)
    reg.add_input_port(CombineRGBA, "outputFormat", basic.String)
    reg.add_output_port(CombineRGBA, "output", basic.File)
Ejemplo n.º 7
0
def initialize(namemodule, namespace, identifier, version):
    reg = get_module_registry()

    enumerationConstant = new_module(Constant, namemodule, {})
    enumerationConstant.name = namemodule
    enumerationConstant.isEnumeration = True
    reg.add_module(enumerationConstant,
                   namespace=namespace,
                   package=identifier,
                   package_version=version)

    return enumerationConstant
Ejemplo n.º 8
0
    def createPackage(self):
        reg = vistrails.core.modules.module_registry.get_module_registry()
        if self.signature in reg.packages:
            reg.remove_package(reg.packages[self.signature])

        # create a document hash integer from the cached sax tree
        # "name" is what suds use as the cache key
        name = '%s-%s' % (abs(hash(self.address)), "wsdl")
        wsdl = package_cache.get(name)
        if not wsdl:
            debug.critical("File not found in SUDS cache: '%s'" % name)
            self.wsdlHash = '0'
            return
        self.wsdlHash = str(int(hashlib.md5(str(wsdl.root)).hexdigest(), 16))

        package_id = reg.idScope.getNewId(Package.vtType)
        package = Package(
            id=package_id,
            load_configuration=False,
            name="SUDS#" + self.address,
            identifier=self.signature,
            version=self.wsdlHash,
        )
        suds_package = reg.get_package_by_name(identifier)
        package._module = suds_package.module
        package._init_module = suds_package.init_module

        self.package = package
        reg.add_package(package)
        reg.signals.emit_new_package(self.signature)

        self.module = new_module(Module, str(self.signature))
        reg.add_module(
            self.module, **{
                'package': self.signature,
                'package_version': self.wsdlHash,
                'abstract': True
            })
Ejemplo n.º 9
0
    def createFailedPackage(self):
        """ Failed package is created so that the user can remove
        it manually using package submenu """
        pm = get_package_manager()
        if pm.has_package(self.signature):
            # do nothing
            return
        reg = vistrails.core.modules.module_registry.get_module_registry()

        # create a document hash integer from the cached sax tree
        # "name" is what suds use as the cache key
        name = '%s-%s' % (abs(hash(self.address)), "wsdl")
        self.wsdlHash = '0'

        package_id = reg.idScope.getNewId(Package.vtType)
        package = Package(
            id=package_id,
            load_configuration=False,
            name="SUDS#" + self.address,
            identifier=self.signature,
            version=self.wsdlHash,
        )
        suds_package = reg.get_package_by_name(identifier)
        package._module = suds_package.module
        package._init_module = suds_package.init_module
        self.package = package
        reg.add_package(package)
        reg.signals.emit_new_package(self.signature)
        self.module = new_module(Module, str(self.signature))
        reg.add_module(
            self.module, **{
                'package': self.signature,
                'package_version': self.wsdlHash,
                'abstract': True
            })
        self.service = -1
Ejemplo n.º 10
0
    def createMethodClasses(self):
        # register modules
        reg = vistrails.core.modules.module_registry.get_module_registry()
        self.methodClasses = {}
        for m in self.wsmethods.itervalues():
            def compute(self):
                # create dict of inputs
                cacheable = False
                if self.hasInputFromPort('cacheable'):
                    cacheable = self.getInputFromPort('cacheable')
                self.is_cacheable = lambda *args, **kwargs: cacheable            
                params = {}
                mname = self.wsmethod.qname[0]
                for name in self.wsmethod.inputs:
                    name = str(name)
                    if self.hasInputFromPort(name):
                        params[name] = self.getInputFromPort(name)
                        if params[name].__class__.__name__ == 'UberClass':
                            params[name] = params[name].value
                        params[name] = self.service.makeDictType(params[name])
                try:
                    #import logging
                    #logging.basicConfig(level=logging.INFO)
                    #logging.getLogger('suds.client').setLevel(logging.DEBUG)
                    #print "params:", str(params)[:400]
                    #self.service.service.set_options(retxml = True)
                    #result = getattr(self.service.service.service, mname)(**params)
                    #print "result:", str(result)[:400]
                    #self.service.service.set_options(retxml = False)
                    result = getattr(self.service.service.service, mname)(**params)
                except Exception, e:
                    raise ModuleError(self, "Error invoking method %s: %s"%(name, str(e)))
                for name, qtype in self.wsmethod.outputs.iteritems():
                    if isinstance(result, list):
                        # if result is a list just set the output
                        self.setResult(name, result)
                    elif qtype[0] == 'Array':
                        # if result is a type but type is a list try to extract the correct element
                        if len(result.__keylist__):
                            self.setResult(name, getattr(result, result.__keylist__[0]))
                        else:
                            self.setResult(name, result)
                    elif result.__class__.__name__ == 'Text':
                        # only text returned so we assume each output wants all of it
                        self.setResult(name, str(result.trim()))
                    elif result.__class__.__name__ == qtype[0]:
                        # the return value is this type
                        self.setResult(name, result)
                    elif hasattr(result, name):
                        self.setResult(name, getattr(result, name))
                    else:
                        # nothing matches - assume it is an attribute of the correct class
                        class UberClass:
                            def __init__(self, value):
                                self.value = value
                        self.setResult(name, UberClass(result))

            # create docstring
            inputs = ", ".join([t[0]+' '+i for i,t in m.inputs.iteritems()])
            outputs = ", ".join([t[0]+' '+o for o,t in m.outputs.iteritems()])
            d = """This module was created using a wrapper for SUDS (fedorahosted.org/suds/)
from the WSDL spec at:
   %s
It is a WSDL method with signature:
   %s(%s)
Outputs:
   (%s)
"""%(self.address, m.qname[0], inputs, outputs)

            M = new_module(self.module, str(m.qname[0]), {"compute":compute,
                                                          "wsmethod":m,
                                                          "service":self,
                                                           "__doc__":d})
            self.methodClasses[m.qname] = M
            reg.add_module(M, **{'namespace':'Methods',
                                 'package':self.signature,
                                 'package_version':self.wsdlHash})
            reg.add_input_port(self.methodClasses[m.qname], 'cacheable',
                               wsdlTypesDict['boolean'], optional=True)

            # add ports
            for p, ptype in m.inputs.iteritems():
                if ptype[1] in wsdlSchemas:
                    c = wsdlTypesDict[ptype[0]]
                elif ptype in self.typeClasses:
                    c = self.typeClasses[ptype]
                else:
                    # use string as default
                    c = wsdlTypesDict['string']
                reg.add_input_port(M, p, c)
            for p, ptype in m.outputs.iteritems():
                if ptype[1] in wsdlSchemas:
                    c = wsdlTypesDict[ptype[0]]
                elif ptype in self.typeClasses:
                    c = self.typeClasses[ptype]
                else:
                    # use string as default
                    c = wsdlTypesDict['string']
                reg.add_output_port(M, p, c)
Ejemplo n.º 11
0
    def createTypeClasses(self):
        # first create classes
        reg = vistrails.core.modules.module_registry.get_module_registry()
        self.typeClasses = {}
        for t in self.wstypes.itervalues():
            def compute(self):
                """ 1. use type input as object or create new
                    2. add other inputs to obj
                    3. set obj and parts as outputs
                """
                if self.wstype.enum:
                    # only makes sure the enum is one of the valid values
                    p = self.wstype.parts['value']
                    if self.hasInputFromPort(p.name):
                        obj = self.getInputFromPort(p.name)
                    else:
                        obj = p.enum[0] if len(p.enum) else ''
                    if self.hasInputFromPort('value'):
                        obj = self.getInputFromPort('value')
                    if obj not in p.enum:
                        raise ModuleError(self,
                                 "'%s' is not one of the valid enums: %s" %
                                 (obj, str(p.enum)) )
                    self.setResult(self.wstype.qname[0], obj)
                    self.setResult('value', obj)
                    return
                if self.hasInputFromPort(self.wstype.qname[0]):
                    obj = self.getInputFromPort(self.wstype.qname[0])
                else:
                    obj = {}
                    s = "{%s}%s"%(self.wstype.qname[1],self.wstype.qname[0])
                    try:
                        obj = self.service.service.factory.create(s)
                    except (suds.TypeNotFound, suds.BuildError):
                        raise ModuleError("Type not found: %s" % s)
                for part in self.wstype.parts.itervalues():
                    # 
                    if obj.__class__.__name__ == 'UberClass':
                        # UberClass is a placeholder and its value is assumed
                        # to be the correct attribute value
                        if len(self.wstype.parts) == 1:
                            setattr(obj, part.name, obj.value)
                        else:
                            # update each attribute
                            if hasattr(obj.value, part.name):
                                setattr(obj, part.name, getattr(obj.value, part.name))
                    if self.hasInputFromPort(part.name):
                        p = self.getInputFromPort(part.name)
                        if hasattr(obj, part.name):
                            setattr(obj, part.name, p)
                        else:
                            # do it anyway - assume attribute missing in template
                            setattr(obj, part.name, p)
                    if hasattr(obj, part.name):
                        # 
                        res = getattr(obj, part.name)
                        self.setResult(part.name, res)
                self.setResult(self.wstype.qname[0], obj)

            # create docstring
            parts = ", ".join([i.type[0]+' '+i.name for i in t.parts.itervalues()])
            d = """This module was created using a wrapper for SUDS (fedorahosted.org/suds/)
from the WSDL spec at:
   %s
It is a WSDL type with signature:
   %s(%s)"""%(self.address, t.qname[0], parts)
            M = new_module(self.module, str(t.qname[0]),{"compute":compute,
                                                         "wstype":t,
                                                         "service":self,
                                                         "__doc__":d})
            self.typeClasses[t.qname] = M
            reg.add_module(M, **{'namespace':'Types',
                                 'package':self.signature,
                                 'package_version':self.wsdlHash})

        # then add ports
        for t in self.wstypes:
            wstype = self.wstypes[t]
            # get type module
            if t[1] in wsdlSchemas:
                c = wsdlTypesDict[t[0]]
            elif t in self.typeClasses:
                c = self.typeClasses[t]
            else:
                debug.critical("Cannot find module for type: " + str(t))
                continue
            # add self ports
            reg.add_input_port(self.typeClasses[t], t[0], c)
            reg.add_output_port(self.typeClasses[t], t[0], c)
            for p in wstype.parts:
                part = wstype.parts[p]
                # get type module
                ptype = part.type
                if part.max is not None and (part.max == 'unbounded' or int(part.max)>1):
                    # it can be multiple objects which means we need to make it a list
                    c = vistrails.core.modules.basic_modules.List
                elif ptype[1] in wsdlSchemas:
                    c = wsdlTypesDict[ptype[0]]
                elif ptype in self.typeClasses:
                    c = self.typeClasses[ptype]
                else:
                    debug.critical("Cannot find module for type: " + str(ptype))
                    continue
                # add as both input and output port
                reg.add_input_port(self.typeClasses[t], p, c,
                                   optional=part.optional)
                reg.add_output_port(self.typeClasses[t], p, c,
                                    optional=part.optional)
Ejemplo n.º 12
0
    def createTypeClasses(self):
        # first create classes
        reg = vistrails.core.modules.module_registry.get_module_registry()
        self.typeClasses = {}
        for t in self.wstypes.itervalues():

            def compute(self):
                """ 1. use type input as object or create new
                    2. add other inputs to obj
                    3. set obj and parts as outputs
                """
                if self.wstype.enum:
                    # only makes sure the enum is one of the valid values
                    p = self.wstype.parts['value']
                    if self.has_input(p.name):
                        obj = self.get_input(p.name)
                    else:
                        obj = p.enum[0] if len(p.enum) else ''
                    if self.has_input('value'):
                        obj = self.get_input('value')
                    if obj not in p.enum:
                        raise ModuleError(
                            self, "'%s' is not one of the valid enums: %s" %
                            (obj, str(p.enum)))
                    self.set_output(self.wstype.qname[0], obj)
                    self.set_output('value', obj)
                    return
                if self.has_input(self.wstype.qname[0]):
                    obj = self.get_input(self.wstype.qname[0])
                else:
                    obj = {}
                    s = "{%s}%s" % (self.wstype.qname[1], self.wstype.qname[0])
                    try:
                        obj = self.service.service.factory.create(s)
                    except (suds.TypeNotFound, suds.BuildError):
                        raise ModuleError("Type not found: %s" % s)
                for part in self.wstype.parts.itervalues():
                    #
                    if obj.__class__.__name__ == 'UberClass':
                        # UberClass is a placeholder and its value is assumed
                        # to be the correct attribute value
                        if len(self.wstype.parts) == 1:
                            setattr(obj, part.name, obj.value)
                        else:
                            # update each attribute
                            if hasattr(obj.value, part.name):
                                setattr(obj, part.name,
                                        getattr(obj.value, part.name))
                    if self.has_input(part.name):
                        p = self.get_input(part.name)
                        if hasattr(obj, part.name):
                            setattr(obj, part.name, p)
                        else:
                            # do it anyway - assume attribute missing in template
                            setattr(obj, part.name, p)
                    if hasattr(obj, part.name):
                        #
                        res = getattr(obj, part.name)
                        self.set_output(part.name, res)
                self.set_output(self.wstype.qname[0], obj)

            # create docstring
            parts = ", ".join(
                [i.type[0] + ' ' + i.name for i in t.parts.itervalues()])
            d = """This module was created using a wrapper for SUDS (fedorahosted.org/suds/)
from the WSDL spec at:
   %s
It is a WSDL type with signature:
   %s(%s)""" % (self.address, t.qname[0], parts)
            M = new_module(self.module, str(t.qname[0]), {
                "compute": compute,
                "wstype": t,
                "service": self,
                "__doc__": d
            })
            self.typeClasses[t.qname] = M
            reg.add_module(
                M, **{
                    'namespace': 'Types',
                    'package': self.signature,
                    'package_version': self.wsdlHash
                })

        # then add ports
        for t in self.wstypes:
            wstype = self.wstypes[t]
            # get type module
            if t[1] in wsdlSchemas:
                c = wsdlTypesDict[t[0]]
            elif t in self.typeClasses:
                c = self.typeClasses[t]
            else:
                debug.critical("Cannot find module for type: " + str(t))
                continue
            # add self ports
            reg.add_input_port(self.typeClasses[t], t[0], c)
            reg.add_output_port(self.typeClasses[t], t[0], c)
            for p in wstype.parts:
                part = wstype.parts[p]
                # get type module
                ptype = part.type
                if part.max is not None and (part.max == 'unbounded'
                                             or int(part.max) > 1):
                    # it can be multiple objects which means we need to make it a list
                    c = vistrails.core.modules.basic_modules.List
                elif ptype[1] in wsdlSchemas:
                    c = wsdlTypesDict[ptype[0]]
                elif ptype in self.typeClasses:
                    c = self.typeClasses[ptype]
                else:
                    debug.critical("Cannot find module for type: " +
                                   str(ptype))
                    continue
                # add as both input and output port
                reg.add_input_port(self.typeClasses[t],
                                   p,
                                   c,
                                   optional=part.optional)
                reg.add_output_port(self.typeClasses[t],
                                    p,
                                    c,
                                    optional=part.optional)
Ejemplo n.º 13
0
    def createMethodClasses(self):
        # register modules
        reg = vistrails.core.modules.module_registry.get_module_registry()
        self.methodClasses = {}
        for m in self.wsmethods.itervalues():

            def compute(self):
                # create dict of inputs
                cacheable = False
                if self.has_input('cacheable'):
                    cacheable = self.get_input('cacheable')
                self.is_cacheable = lambda *args, **kwargs: cacheable
                params = {}
                mname = self.wsmethod.qname[0]
                for name in self.wsmethod.inputs:
                    name = str(name)
                    if self.has_input(name):
                        params[name] = self.get_input(name)
                        if params[name].__class__.__name__ == 'UberClass':
                            params[name] = params[name].value
                        params[name] = self.service.makeDictType(params[name])
                try:
                    #import logging
                    #logging.basicConfig(level=logging.INFO)
                    #logging.getLogger('suds.client').setLevel(logging.DEBUG)
                    #print "params:", str(params)[:400]
                    #self.service.service.set_options(retxml = True)
                    #result = getattr(self.service.service.service, mname)(**params)
                    #print "result:", str(result)[:400]
                    #self.service.service.set_options(retxml = False)
                    result = getattr(self.service.service.service,
                                     mname)(**params)
                except Exception, e:
                    debug.unexpected_exception(e)
                    raise ModuleError(
                        self, "Error invoking method %s: %s" %
                        (mname, debug.format_exception(e)))
                for name, qtype in self.wsmethod.outputs.iteritems():
                    if isinstance(result, list):
                        # if result is a list just set the output
                        self.set_output(name, result)
                    elif qtype[0] == 'Array':
                        # if result is a type but type is a list try to extract the correct element
                        if len(result.__keylist__):
                            self.set_output(
                                name, getattr(result, result.__keylist__[0]))
                        else:
                            self.set_output(name, result)
                    elif result.__class__.__name__ == 'Text':
                        # only text returned so we assume each output wants all of it
                        self.set_output(name, str(result.trim()))
                    elif result.__class__.__name__ == qtype[0]:
                        # the return value is this type
                        self.set_output(name, result)
                    elif hasattr(result, name):
                        self.set_output(name, getattr(result, name))
                    else:
                        # nothing matches - assume it is an attribute of the correct class
                        class UberClass(object):
                            def __init__(self, value):
                                self.value = value

                        self.set_output(name, UberClass(result))

            # create docstring
            inputs = ", ".join(
                [t[0] + ' ' + i for i, t in m.inputs.iteritems()])
            outputs = ", ".join(
                [t[0] + ' ' + o for o, t in m.outputs.iteritems()])
            d = """This module was created using a wrapper for SUDS (fedorahosted.org/suds/)
from the WSDL spec at:
   %s
It is a WSDL method with signature:
   %s(%s)
Outputs:
   (%s)
""" % (self.address, m.qname[0], inputs, outputs)

            M = new_module(self.module, str(m.qname[0]), {
                "compute": compute,
                "wsmethod": m,
                "service": self,
                "__doc__": d
            })
            self.methodClasses[m.qname] = M
            reg.add_module(
                M, **{
                    'namespace': 'Methods',
                    'package': self.signature,
                    'package_version': self.wsdlHash
                })
            reg.add_input_port(self.methodClasses[m.qname],
                               'cacheable',
                               wsdlTypesDict['boolean'],
                               optional=True)

            # add ports
            for p, ptype in m.inputs.iteritems():
                if ptype[1] in wsdlSchemas:
                    c = wsdlTypesDict[ptype[0]]
                elif ptype in self.typeClasses:
                    c = self.typeClasses[ptype]
                else:
                    # use string as default
                    c = wsdlTypesDict['string']
                reg.add_input_port(M, p, c)
            for p, ptype in m.outputs.iteritems():
                if ptype[1] in wsdlSchemas:
                    c = wsdlTypesDict[ptype[0]]
                elif ptype in self.typeClasses:
                    c = self.typeClasses[ptype]
                else:
                    # use string as default
                    c = wsdlTypesDict['string']
                reg.add_output_port(M, p, c)
Ejemplo n.º 14
0
    # necessary for group
    d['_input_ports'] = [IPort(*p[:3], depth=p[3]) for p in input_ports] 
    d['_output_ports'] = [OPort(*p[:3], depth=p[3]) for p in output_ports] 
    d['input_remap'] = input_remap
    d['output_remap'] = output_remap
    d['pipeline'] = pipeline

    # abstraction specific
    d['vt_fname'] = vt_fname
    d['vistrail'] = vistrail
    d['internal_version'] = internal_version
    d['uuid'] = uuid

    # print "input_ports", d['_input_ports']
    # print "output_ports", d['_output_ports']
    return new_module(Abstraction, name, d, docstring)

def get_abstraction_dependencies(vistrail, internal_version=-1L):
    if isinstance(vistrail, basestring):
        vistrail = read_vistrail(vistrail)
    if internal_version == -1L:
        internal_version = vistrail.get_latest_version()
    pipeline = vistrail.getPipeline(internal_version)

    packages = {}
    def pipeline_deps(pipeline):
        for module in pipeline.module_list:
            if module.is_group():
                pipeline_deps(module.pipeline)
                continue
            if module.package not in packages:
Ejemplo n.º 15
0
    # necessary for group
    d['_input_ports'] = [IPort(*p[:3], depth=p[3]) for p in input_ports] 
    d['_output_ports'] = [OPort(*p[:3], depth=p[3]) for p in output_ports] 
    d['input_remap'] = input_remap
    d['output_remap'] = output_remap
    d['pipeline'] = pipeline

    # abstraction specific
    d['vt_fname'] = vt_fname
    d['vistrail'] = vistrail
    d['internal_version'] = internal_version
    d['uuid'] = uuid

    # print "input_ports", d['_input_ports']
    # print "output_ports", d['_output_ports']
    return new_module(Abstraction, name, d, docstring)

def get_abstraction_dependencies(vistrail, internal_version=-1L):
    if isinstance(vistrail, basestring):
        vistrail = read_vistrail(vistrail)
    if internal_version == -1L:
        internal_version = vistrail.get_latest_version()
    # action = vistrail.actionMap[internal_version]
    pipeline = vistrail.getPipeline(internal_version)
    
    packages = {}
    for module in pipeline.module_list:
        if module.package not in packages:
            packages[module.package] = set()
        packages[module.package].add(module.descriptor_info)
    return packages
Ejemplo n.º 16
0
                    f = open(file.name, 'wb')
                    f.write(stderr)
                    f.close()
                    self.set_output(name, file)
                elif "string" == type:
                    self.set_output(name, stderr)
                else: # pragma: no cover
                    raise ValueError


    # create docstring
    d = """This module is a wrapper for the command line tool '%s'""" % \
        conf['command']
    # create module
    M = new_module(CLTools, tool_name, {"compute": compute,
                                        "conf": conf,
                                        "tool_name": tool_name,
                                        "__doc__": d})
    reg = vistrails.core.modules.module_registry.get_module_registry()
    reg.add_module(M, package=identifiers.identifier,
                   package_version=identifiers.version)

    def to_vt_type(s):
        # add recognized types here - default is String
        return '(basic:%s)' % \
          {'file':'File', 'path':'Path', 'directory': 'Directory',
           'flag':'Boolean', 'list':'List',
           'float':'Float','integer':'Integer'
          }.get(s.lower(), 'String')
    # add module ports
    if 'stdin' in conf:
        name, type, options = conf['stdin']
Ejemplo n.º 17
0
                    f = open(file.name, 'wb')
                    f.write(stderr)
                    f.close()
                    self.set_output(name, file)
                elif "string" == type:
                    self.set_output(name, stderr)
                else:  # pragma: no cover
                    raise ValueError

    # create docstring
    d = """This module is a wrapper for the command line tool '%s'""" % \
        conf['command']
    # create module
    M = new_module(CLTools, tool_name, {
        "compute": compute,
        "conf": conf,
        "tool_name": tool_name,
        "__doc__": d
    })
    reg = vistrails.core.modules.module_registry.get_module_registry()
    reg.add_module(M,
                   package=identifiers.identifier,
                   package_version=identifiers.version)

    def to_vt_type(s):
        # add recognized types here - default is String
        return '(basic:%s)' % \
          {'file':'File', 'path':'Path', 'directory': 'Directory',
           'flag':'Boolean', 'list':'List',
           'float':'Float','integer':'Integer'
          }.get(s.lower(), 'String')