def __init__(self, address):
        """ Process WSDL and add all Types and Methods
        """
        self.address = address
        self.signature = toSignature(self.address)
        self.wsdlHash = '-1'
        self.modules = []
        self.package = None
        debug.log("Installing Web Service from WSDL: %s"% address)

        options = dict(cachingpolicy=1, cache=package_cache)
        
        proxy_types = ['http']
        for t in proxy_types:
            key = 'proxy_%s'%t
            if configuration.check(key):
                proxy = getattr(configuration, key)
                debug.log("Using proxy: %s" % proxy)
                if len(proxy):
                    options['proxy'] = {t:proxy}
        try:
            self.service = suds.client.Client(address, **options)
            self.backUpCache()
        except Exception, e:
            self.service = None
            # We may be offline and the cache may have expired,
            # try to use backup
            if self.restoreFromBackup():
                try:
                    self.service = suds.client.Client(address, **options)
                except Exception, e:
                    self.service = None
                    debug.critical("Could not load WSDL: %s" % address,
                           str(e) + '\n' + str(traceback.format_exc()))
def handle_missing_module(controller, module_id, pipeline):
    global webServicesDict
    global package_cache

    def get_wsdl_from_namespace(m_namespace):
        try:
            wsdl = m_namespace.split("|")
            return wsdl[0]
        except:
            return None
    
    m = pipeline.modules[module_id]
    if m.package == identifier:
        # v1.0 old style
        m_namespace = m.namespace
        wsdl = get_wsdl_from_namespace(m_namespace)
    else:
        # v1.1 new style
        wsdl = toAddress(m.name)
    
    wsdlList = []
    if configuration.check('wsdlList'):
        wsdlList = configuration.wsdlList.split(";")
    if wsdl in wsdlList:
        # it is already loaded
        return True

    service = Service(wsdl)
    if not service.service:
        return False

    webServicesDict[wsdl] = service
    wsdlList.append(wsdl)
    configuration.wsdlList = ';'.join(wsdlList)
    return True
Пример #3
0
    def compute(self):
        o = self.create_output_file()
        r = self.getInputFromPort("r")
        g = self.getInputFromPort("g")
        b = self.getInputFromPort("b")
        a = self.getInputFromPort("a")

        path = None
        if configuration.check('path'):
            path = configuration.path
        if path:
            cmd = os.path.join(path, 'convert')
        else:
            cmd = 'convert'
        cmd = [
            cmd, '-channel', 'RGBA', '-combine', r.name, g.name, b.name,
            a.name, o.name
        ]
        if not configuration.quiet:
            debug.log(cmd)
        cmdline = list2cmdline(cmd)
        result = os.system(cmdline)
        if result != 0:
            raise ModuleError(self, "system call failed: '%s'" % cmdline)
        self.setResult("output", o)
def initialize(*args, **keywords):
#    import core.packagemanager
    global webServicesDict
    global package_cache

    #Create a directory for the SUDSWebServices package
    location = os.path.join(core.system.default_dot_vistrails(),
                                     "SUDSWebServices")
    if not os.path.isdir(location):
        try:
            debug.log("Creating SUDS cache directory...")
            os.mkdir(location)
        except:
            debug.critical(
"""Could not create SUDS cache directory. Make sure
'%s' does not exist and parent directory is writable""" % location)
            sys.exit(1)
    # the number of days to cache wsdl files
    days = 1
    if configuration.check("cache_days"):
        days = configuration.cache_days
    suds.client.ObjectCache.protocol = 0 # windows needs this
    package_cache = suds.client.ObjectCache(location, days=days)

    reg = core.modules.module_registry.get_module_registry()
    reg.add_module(SUDSWebService, **{'hide_descriptor':True})

    wsdlList = []
    if configuration.check('wsdlList'):
        wsdlList = configuration.wsdlList.split(";")
    for wsdl in wsdlList:
        if not wsdl.startswith('http://'):
            wsdl = 'http://' + wsdl
        if wsdl in webServicesDict:
            debug.warning('Duplicate WSDL entry: '+wsdl)
            continue
        s = Service(wsdl)
        if s.service:
            webServicesDict[wsdl] = s
    def run(self, *args):
        """run(*args), runs ImageMagick's 'convert' on a shell, passing all
arguments to the program."""
        path = None
        if configuration.check('path'):
            path = configuration.path
        if path:
            cmd = os.path.join(path,'convert')
        else:
            cmd = 'convert'    
        cmd = [cmd] + list(args)
        cmdline = list2cmdline(cmd)
        if not configuration.quiet:
            debug.log(cmdline)
        r = os.system(cmdline)
        if r != 0:
            raise ModuleError(self, "system call failed: '%s'" % cmdline)
def load_from_signature(signature):
    """ Load wsdl from signature and return success status """
    wsdl = toAddress(signature)
    wsdlList = []
    if configuration.check('wsdlList'):
        wsdlList = configuration.wsdlList.split(";")
    if not wsdl in wsdlList:
        try:
            service = Service(wsdl)
        except:
            return False
        if not service.service:
            return False
        webServicesDict[wsdl] = service
        wsdlList.append(wsdl)
        configuration.wsdlList = ';'.join(wsdlList)
    return True
Пример #7
0
    def run(self, *args):
        """run(*args), runs ImageMagick's 'convert' on a shell, passing all
arguments to the program."""
        path = None
        if configuration.check('path'):
            path = configuration.path
        if path:
            cmd = os.path.join(path, 'convert')
        else:
            cmd = 'convert'
        cmd = [cmd] + list(args)
        cmdline = list2cmdline(cmd)
        if not configuration.quiet:
            debug.log(cmdline)
        r = os.system(cmdline)
        if r != 0:
            raise ModuleError(self, "system call failed: '%s'" % cmdline)
 def compute(self):
     o = self.create_output_file()
     r = self.getInputFromPort("r")
     g = self.getInputFromPort("g")
     b = self.getInputFromPort("b")
     a = self.getInputFromPort("a")
     
     path = None
     if configuration.check('path'):
         path = configuration.path
     if path:
         cmd = os.path.join(path,'convert')
     else:
         cmd = 'convert'    
     cmd = [cmd, '-channel', 'RGBA', '-combine',
            r.name, g.name, b.name, a.name, o.name]
     if not configuration.quiet:
         debug.log(cmd)
     cmdline = list2cmdline(cmd)
     result = os.system(cmdline)
     if result != 0:
         raise ModuleError(self, "system call failed: '%s'" % cmdline)
     self.setResult("output", o)
def handle_module_upgrade_request(controller, module_id, pipeline):
    old_module = pipeline.modules[module_id]
    # first check package
    # v1.0 types:
    if old_module.package == 'edu.utah.sci.vistrails.sudswebservices':
        wsdl = old_module.namespace.split('|')[0]
        namespace = old_module.namespace.split('|')[1]
    else:
        wsdl = toAddress(old_module.package)
        namespace = old_module.namespace
    name = old_module.name

    wsdlList = []
    if configuration.check('wsdlList'):
        wsdlList = configuration.wsdlList.split(";")
    if not wsdl in wsdlList:
        service = Service(wsdl)
        if not service.service:
            return []
        webServicesDict[wsdl] = service
        wsdlList.append(wsdl)
        configuration.wsdlList = ';'.join(wsdlList)

    if old_module.package == 'edu.utah.sci.vistrails.sudswebservices':
        reg = core.modules.module_registry.get_module_registry()
        new_descriptor = reg.get_descriptor_by_name(toSignature(wsdl), name,
                                                    namespace)
        if not new_descriptor:
            return []
        try:
            return UpgradeWorkflowHandler.replace_module(controller, pipeline,
                                                    module_id, new_descriptor)
        except Exception, e:
            import traceback
            traceback.print_exc()
            raise