How to use the pywps.config function in pywps

To help you get started, we’ve selected a few pywps examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github geopython / pywps / tests / perform_requests.py View on Github external
xmldom = minidom.parseString(getpywps.response)
        self.assertFalse(len(xmldom.getElementsByTagNameNS(self.wpsns,"ExceptionReport")), 0)
  
        # try to get out the Reference elemengt
        wfsurl = xmldom.getElementsByTagNameNS(self.wpsns,"Reference")[0].getAttribute("href")
        print wfsurl
        #wcsurl = xmldom.getElementsByTagNameNS(self.wpsns,"Reference")[1].getAttribute("href")
        wfsurl=urllib.unquote(wfsurl)
        inSource=osgeo.ogr.Open(wfsurl)
        self.assertTrue(isinstance(inSource,osgeo.ogr.DataSource))
        inLayer=inSource.GetLayer()
        self.assertTrue(isinstance(inLayer,osgeo.ogr.Layer))
        self.assertTrue(isinstance(inLayer.GetNextFeature(),osgeo.ogr.Feature))
        
        #check for mutiple projections from config file
        projs=pywps.config.getConfigValue("mapserver","projs")
        #convert to list 
        projs=re.findall(r'\d+',projs)
        wfs110url=wfsurl.lower().replace("1.0.0","1.1.0").replace("getfeature","getcapabilities")
        try:
            wfsDom=minidom.parse(urllib.urlopen(wfs110url))
            defaultProj=wfsDom.getElementsByTagName("DefaultSRS")[0].firstChild.nodeValue #urn:ogc:def:crs:EPSG::4326
        except:
            assert False
        
        self.assertTrue(projs[0] in defaultProj)
        try:
            otherProjs=wfsDom.getElementsByTagName("OtherSRS") #urn:ogc:def:crs:EPSG::4326
        except:
            assert False
        self.assertTrue(len(otherProjs)==(len(projs)-1))
github geopython / pywps / tests / perform_requests.py View on Github external
ogrns = "http://ogr.maptools.org/"
    
    #Generic external data
    simplePolyURL="http://rsg.pml.ac.uk/wps/testdata/single_point.gml"
    simpleJPG="http://rsg.pml.ac.uk/wps/testdata/basin_50K_nc.jpg"
    simpleLine="http://openlayers.org/dev/examples/gml/line.xml"
    
    #FTP parameters for test20FTPSupport
    #Pure PyWPS ftp configuration
    ftpLogin="user"
    ftpPasswd="12345"
    ftpPort=6666 # something above 1024 to avoid root permission
    outputPath="ftp://localhost"
    outputURL="ftp://localhost"
    #ftpServer variables
    ftpPath=pywps.config.getConfigValue("server","tempPath")
    ftpHost="127.0.0.1"
    ftpPerm="elradfmw"
    
    xmldom = None

    def setUp(self):
        #Silence PyWPS Warning:       from pywps.Process.Process import WPSProcess
        sys.stderr=open("/dev/null","w")

    def testT00Assync(self):
        """Test asynchronous mode for the first time"""
  
        self._setFromEnv()
        mypywps = pywps.Pywps(pywps.METHOD_GET)
        inputs = mypywps.parseRequest("service=wps&request=execute&version=1.0.0&identifier=asyncprocess&status=true&storeExecuteResponse=true")
        self.assertEquals(mypywps.inputs["request"], "execute")
github geopython / pywps / tests / schema_validation.py View on Github external
file should NOT be empty"""
        self._setFromEnv()
        
        schemaDocExecute=etree.XML(urllib.urlopen(self.executeSchemaResponse).read(),parser=self.parser,base_url=self.base_url)
        schemaExecute=etree.XMLSchema(schemaDocExecute)
        
        mypywps = pywps.Pywps(pywps.METHOD_GET)
        inputs = mypywps.parseRequest("service=wps&request=execute&version=1.0.0&identifier=ultimatequestionprocess&status=false&storeExecuteResponse=true")
        mypywps.performRequest()
        
        #First parse
        executeAssyncGET=etree.XML(mypywps.response,self.parser)
        self.assertEquals(schemaExecute.assertValid(executeAssyncGET),None)
        #get path to status document
        fileName=os.path.basename(executeAssyncGET.xpath("//*[local-name()='ExecuteResponse']/@statusLocation")[0])
        filePath=pywps.config.getConfigValue("server","outputPath")+"/"+fileName
        self.assertEquals(True,os.path.exists(filePath))
        fileOpen = open(filePath)
        
        self.assertEquals(fileOpen.read(), mypywps.response)
github geopython / pywps / demo / server.py View on Github external
def __init__(self, host='localhost', port='5000', debug=False, processes=[], config_file=None):
        self.app = flask.Flask(__name__)
        self.host = host
        self.port = port
        self.debug = debug

        # Load config files and override settings if any file specified
        if config_file:
            config.load_configuration(config_file)

        self.output_url = config.get_config_value('server', 'outputUrl')
        self.output_path = config.get_config_value('server', 'outputPath')
        self.temp_path = config.get_config_value('server', 'tempPath')
        self.host = config.get_config_value('wps', 'serveraddress').split('://')[1]
        self.port = int(config.get_config_value('wps', 'serverport'))

        self.processes = [
            Process(say_hello,
                    version='1.3.3.7',
                    inputs=[LiteralInput('name', data_type='string')],
                    outputs=[LiteralOutput('response', data_type='string')],
                    store_supported=True,
                    status_supported=True),
            Process(feature_count,
                    inputs=[ComplexInput('layer', 'Layer', [Format('SHP')])],
github ESGF / esgf-compute-wps / compute / wps / processes / esgfcwtProcess.py View on Github external
def setEnvVariable( key, env_var ):
    try:
        value = config.getConfigValue( "cds", key )
        os.environ[ env_var ] = value
        setEnv( env_var, value )
        logging.info("CDS environment variable %s set to %s" % ( env_var, value ) )
        for identifier in [ 'path', 'library' ]:
            if identifier in env_var.lower():
                for path in value.split(':'):
                    if path not in sys.path:
                        sys.path.append(path)
                        logging.info("Adding %s to sys.path" % ( path ) )
    except:
        logging.info("Error setting CDS environment variable %s" % ( env_var ) )
github geopython / pywps / demo / server.py View on Github external
def __init__(self, host='localhost', port='5000', debug=False, processes=[], config_file=None):
        self.app = flask.Flask(__name__)
        self.host = host
        self.port = port
        self.debug = debug

        # Load config files and override settings if any file specified
        if config_file:
            config.load_configuration(config_file)

        self.output_url = config.get_config_value('server', 'outputUrl')
        self.output_path = config.get_config_value('server', 'outputPath')
        self.temp_path = config.get_config_value('server', 'tempPath')
        self.host = config.get_config_value('wps', 'serveraddress').split('://')[1]
        self.port = int(config.get_config_value('wps', 'serverport'))

        self.processes = [
            Process(say_hello,
                    version='1.3.3.7',
                    inputs=[LiteralInput('name', data_type='string')],
                    outputs=[LiteralOutput('response', data_type='string')],
                    store_supported=True,
                    status_supported=True),
            Process(feature_count,
                    inputs=[ComplexInput('layer', 'Layer', [Format('SHP')])],
                    outputs=[ComplexOutput('layer', 'Layer', [Format('GML')])]),
            Process(centroids,
                    inputs=[ComplexInput('layer', 'Layer', [Format('GML')])],
                    outputs=[ComplexOutput('out', 'Referenced Output', [Format('JSON')])],
                    store_supported=True,
                    status_supported=True),
github geopython / pywps / pywps / Wps / Execute.py View on Github external
def _initMapscript(self):
        """Create self.mapObj"""

        self.mapObj = mapObj()
        self.mapObj.setExtent(-180,-90,180,90)
        self.mapObj.setProjection("+init=epsg:4326")
        self.mapObj.name = "%s-%s"%(self.process.identifier,self.pid)
        self.mapObj.setMetaData("ows_title", config.getConfigValue("wps","title"))
        self.mapObj.setMetaData("wms_abstract", config.getConfigValue("wps","abstract"))
        self.mapObj.setMetaData("wcs_abstract", config.getConfigValue("wps","abstract"))
        self.mapObj.setMetaData("wfs_abstract", config.getConfigValue("wps","abstract"))
        self.mapObj.setMetaData("ows_keywordlist", config.getConfigValue("wps","keywords"))
        self.mapObj.setMetaData("ows_fees", config.getConfigValue("wps","fees"))
        self.mapObj.setMetaData("ows_accessconstraints", config.getConfigValue("wps","constraints"))
        self.mapObj.setMetaData("ows_contactorganization", config.getConfigValue("provider","providerName"))
        self.mapObj.setMetaData("ows_contactperson", config.getConfigValue("provider","individualName"))
        self.mapObj.setMetaData("ows_contactposition", config.getConfigValue("provider","positionName"))
        phone =  config.getConfigValue("provider","phoneVoice")
        if phone:
            self.mapObj.setMetaData("ows_contactvoicetelephone", config.getConfigValue("provider","phoneVoice"))
        phone = config.getConfigValue("provider","phoneFacsimile")
        if phone:
            self.mapObj.setMetaData("ows_contactfacsimiletelephone", config.getConfigValue("provider","phoneFacsimile"))
        self.mapObj.setMetaData("ows_address", config.getConfigValue("provider","deliveryPoint"))
        self.mapObj.setMetaData("ows_city", config.getConfigValue("provider","city"))
        self.mapObj.setMetaData("ows_country", config.getConfigValue("provider","country"))
        self.mapObj.setMetaData("ows_postcode", config.getConfigValue("provider","postalCode"))
        self.mapObj.setMetaData("ows_contactelectronicmailaddress", config.getConfigValue("provider","electronicMailAddress"))
        self.mapObj.setMetaData("ows_role", config.getConfigValue("provider","role"))
github geopython / pywps / pywps / Wps / Execute / UMN.py View on Github external
def __init__(self,process,sessId):

        if ((mapscript == False) or (gdal== False)):
            return
        
        tmp = os.path.basename(tempfile.mkstemp()[1])
        self.outputs = {}
        self.process = process
        self.sessionId = sessId
        self.projs=self.getProjs()
        self.mapObj = mapObj()
        self.mapObj.setExtent(-180,-90,180,90)# irrelevant for WCS/WFS
        #self.mapObj.setProjection("+init=%s" % self.projs[0])
        self.mapObj.name = "%s-%s"%(self.process.identifier,self.sessionId)
        self.mapObj.setMetaData("ows_title", config.getConfigValue("wps","title"))
        self.mapObj.setMetaData("wms_abstract", config.getConfigValue("wps","abstract"))
        self.mapObj.setMetaData("wcs_abstract", config.getConfigValue("wps","abstract"))
        self.mapObj.setMetaData("wcs_label", process.title)
        self.mapObj.setMetaData("wfs_abstract", config.getConfigValue("wps","abstract"))
        self.mapObj.setMetaData("ows_keywordlist", config.getConfigValue("wps","keywords"))
        self.mapObj.setMetaData("ows_fees", config.getConfigValue("wps","fees"))
        self.mapObj.setMetaData("ows_accessconstraints", config.getConfigValue("wps","constraints"))
        self.mapObj.setMetaData("ows_contactorganization", config.getConfigValue("provider","providerName"))
        self.mapObj.setMetaData("ows_contactperson", config.getConfigValue("provider","individualName"))
        self.mapObj.setMetaData("ows_contactposition", config.getConfigValue("provider","positionName"))
        self.mapObj.setMetaData("ows_enable_request", "*")
        self.mapObj.debug = 5
        self.mapObj.setConfigOption("MS_ERRORFILE", "stderr")
        
        phone =  config.getConfigValue("provider","phoneVoice")
        if phone:
github ESGF / esgf-compute-wps / compute / wps / processes / cdat / averager.py View on Github external
def __call__(self, data_manager, status):
        axes = self.parameter('axes')

        var = data_manager.open(self.input()[0])

        var_axes = var.cdms_variable.getAxisIds()

        try:
            axes_arg = ''.join([str(var_axes.index(x)) for x in axes.values])
        except ValueError as e:
            raise esgf.WPSServerError('Dimension %s of variable dimensions %s' % (e.message, var_axes))

        avg = cdutil.averager(var.cdms_variable, axis=axes_arg)

        output_path = config.getConfigValue('server', 'outputPath', '/var/wps')
        new_file_name = '%s.nc' % (str(uuid.uuid4()),)
        new_path = os.path.join(output_path, new_file_name)

        fout = cdms2.open(new_path, 'w')

        fout.write(avg, id=var.cdms_variable.id)

        fout.close()

        dap_url = self.create_dap_url(new_file_name)

        self.set_output(dap_url, var.cdms_variable.id)
github ESGF / esgf-compute-wps / compute / wps / processes / cdat / averger.py View on Github external
status('Averagering "%s" over dimensions "%s"' %
               (input_var.id,
                ', '.join(axes.values)))
        
        start = datetime.datetime.now() 

        new_var = cdutil.averager(input_var, axis=axes_arg)

        #status('Finished averaging in %s' % (datetime.datetime.now()-start,))

        new_var_name = '%s_avg_%s' % (input_var.id, '_'.join(axes.values))

        new_file_name = '%s.nc' % (str(uuid.uuid4()),)

        output_path = config.getConfigValue('server', 'outputPath', '/var/wps')

        new_file = os.path.join(output_path, new_file_name)

        #status('Writing output to "%s"' % (new_file,))

        data_manager.write('file://' + new_file, new_var, new_var_name)

        dap_url = self.create_dap_url(new_file_name)

        self.set_output(dap_url, new_var_name)