How to use the owslib.util.log.debug function in OWSLib

To help you get started, we’ve selected a few OWSLib 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 / OWSLib / owslib / wps.py View on Github external
def _readFromUrl(self, url, data, method='Get', username=None, password=None,
                     headers=None, verify=True, cert=None):
        """
        Method to get and parse a WPS document, returning an elementtree instance.
        :param str url: WPS service base url.
        :param str data: GET: dictionary of HTTP (key, value) parameter pairs, POST: XML document to post
        :param str username: optional user credentials
        :param str password: optional user credentials
        """

        if method == 'Get':
            # full HTTP request url
            request_url = build_get_url(url, data, overwrite=True)
            log.debug(request_url)

            # split URL into base url and query string to use utility function
            spliturl = request_url.split('?')
            u = openURL(spliturl[0], spliturl[
                        1], method='Get', username=username, password=password,
                        headers=headers, verify=verify, cert=cert)
            return etree.fromstring(u.read())

        elif method == 'Post':
            u = openURL(url, data, method='Post',
                        username=username, password=password,
                        headers=headers, verify=verify, cert=cert)
            return etree.fromstring(u.read())

        else:
            raise Exception("Unrecognized HTTP method: %s" % method)
github ESGF / esgf-compute-api / cwt / wps.py View on Github external
def parseResponse(self, response):
        """
        Method to parse a WPS response document
        """

        rootTag = response.tag.split('}')[1]
        # 
        if rootTag == 'ExecuteResponse':
            self._parseExecuteResponse(response)

        # 
        elif rootTag == 'ExceptionReport':
            self._parseExceptionReport(response)

        else:
            log.debug('Unknown Response')

        # log status, errors
        log.info('Execution status=%s' % self.status)
        log.info('Percent completed=%s' % self.percentCompleted)
        log.info('Status message=%s' % self.statusMessage)
        for error in self.errors:
            dump(error)
github ESGF / esgf-compute-api / cwt / wps.py View on Github external
def _readFromUrl(self, url, data, timeout, method='Get', username=None, password=None,
                     headers=None, verify=True, cert=None):
        """
        Method to get and parse a WPS document, returning an elementtree instance.
        :param str url: WPS service base url.
        :param str data: GET: dictionary of HTTP (key, value) parameter pairs, POST: XML document to post
        :param str username: optional user credentials
        :param str password: optional user credentials
        """

        if method == 'Get':
            # full HTTP request url
            request_url = build_get_url(url, data, overwrite=True)
            log.debug(request_url)

            # split URL into base url and query string to use utility function
            spliturl = request_url.split('?')
            u = openURL(spliturl[0], spliturl[
                        1], method='Get', username=username, password=password,
                        headers=headers, verify=verify, cert=cert, timeout=self.timeout)
            return etree.fromstring(u.read())

        elif method == 'Post':
            u = openURL(url, data, method='Post',
                        username=username, password=password,
                        headers=headers, verify=verify, cert=cert, timeout=timeout)
            return etree.fromstring(u.read())

        else:
            raise Exception("Unrecognized HTTP method: %s" % method)
github geopython / OWSLib / owslib / wps.py View on Github external
# 
        if len(self.dataInputs) > 0:
            log.debug('clean data inputs')
            self.dataInputs[:] = []
        for inputElement in root.findall(nspath('DataInputs/Input', ns=wpsns)):
            self.dataInputs.append(Output(inputElement))
            if self.verbose is True:
                dump(self.dataInputs[-1])

        # 
        # xmlns:ns="http://www.opengis.net/wps/1.0.0"
        if len(self.processOutputs) > 0:
            log.debug('clean process outputs')
            self.processOutputs[:] = []
        for outputElement in root.findall(nspath('ProcessOutputs/Output', ns=wpsns)):
            self.processOutputs.append(Output(outputElement))
            if self.verbose is True:
                dump(self.processOutputs[-1])
github ESGF / esgf-compute-api / cwt / wps.py View on Github external
:param request: optional pre-built XML request document, prevents building of request from other arguments
        :param response: optional pre-built XML response document, prevents submission of request to live WPS server
        """

        # instantiate a WPSExecution object
        log.info('Executing WPS request...')
        execution = WPSExecution(version=self.version, url=self.url,
                                 username=self.username, password=self.password, verbose=self.verbose,
                                 headers=self.headers, verify=self.verify, cert=self.cert, timeout=self.timeout)

        # build XML request from parameters
        if request is None:
            requestElement = execution.buildRequest(identifier, inputs, output, mode=mode, lineage=lineage)
            request = etree.tostring(requestElement)
            execution.request = request
        log.debug(request)

        # submit the request to the live server
        if response is None:
            response = execution.submitRequest(request)
        else:
            response = etree.fromstring(response)

        log.debug(etree.tostring(response))

        # parse response
        execution.parseResponse(response)

        return execution
github ESGF / esgf-compute-api / cwt / wps.py View on Github external
inputElement = etree.SubElement(
                dataInputsElement, nspath_eval('wps:Input', namespaces))
            identifierElement = etree.SubElement(
                inputElement, nspath_eval('ows:Identifier', namespaces))
            identifierElement.text = key

            # Literal data
            # 
            #   DATASET_URI
            #   
            #     dods://igsarm-cida-thredds1.er.usgs.gov:8080/thredds/dodsC/dcp/conus_grid.w_meta.ncml
            #   
            # 
            if is_literaldata(val):
                log.debug("literaldata %s", key)
                dataElement = etree.SubElement(
                    inputElement, nspath_eval('wps:Data', namespaces))
                literalDataElement = etree.SubElement(
                    dataElement, nspath_eval('wps:LiteralData', namespaces))
                literalDataElement.text = val

            # Complex data
            # 
            #   FEATURE_COLLECTION
            #   
            #      
            #          # noqa
            #            
            #                the_geom
            #                STATE
            #                
github geopython / OWSLib / owslib / coverage / wcs110.py View on Github external
def getCoverage(self, identifier=None, bbox=None, time=None, format = None, store=False, rangesubset=None, gridbaseCRS=None, gridtype=None, gridCS=None, gridorigin=None, gridoffsets=None, method='Get',**kwargs):
        """Request and return a coverage from the WCS as a file-like object
        note: additional **kwargs helps with multi-version implementation
        core keyword arguments should be supported cross version
        example:
        cvg=wcs.getCoverageRequest(identifier=['TuMYrRQ4'], time=['2792-06-01T00:00:00.0'], bbox=(-112,36,-106,41),format='application/netcdf', store='true')

        is equivalent to:
        http://myhost/mywcs?SERVICE=WCS&REQUEST=GetCoverage&IDENTIFIER=TuMYrRQ4&VERSION=1.1.0&BOUNDINGBOX=-180,-90,180,90&TIMESEQUENCE=2792-06-01T00:00:00.0&FORMAT=application/netcdf
        
        if store = true, returns a coverages XML file
        if store = false, returns a multipart mime
        """
        if log.isEnabledFor(logging.DEBUG):
            log.debug('WCS 1.1.0 DEBUG: Parameters passed to GetCoverage: identifier=%s, bbox=%s, time=%s, format=%s, rangesubset=%s, gridbaseCRS=%s, gridtype=%s, gridCS=%s, gridorigin=%s, gridoffsets=%s, method=%s, other_arguments=%s'%(identifier, bbox, time, format, rangesubset, gridbaseCRS, gridtype, gridCS, gridorigin, gridoffsets, method, str(kwargs)))       
        
        if method == 'Get':
            method=self.ns.WCS_OWS('Get')
        try:
            base_url = next((m.get('url') for m in self.getOperationByName('GetCoverage').methods if m.get('type').lower() == method.lower()))
        except StopIteration:
            base_url = self.url


        #process kwargs
        request = {'version': self.version, 'request': 'GetCoverage', 'service':'WCS'}
        assert len(identifier) > 0
        request['identifier']=identifier
        #request['identifier'] = ','.join(identifier)
        if bbox:
            request['boundingbox']=','.join([repr(x) for x in bbox])
github geopython / OWSLib / owslib / wps.py View on Github external
:param request: optional pre-built XML request document, prevents building of request from other arguments
        :param response: optional pre-built XML response document, prevents submission of request to live WPS server
        """

        # instantiate a WPSExecution object
        log.info('Executing WPS request...')
        execution = WPSExecution(version=self.version, url=self.url,
                                 username=self.username, password=self.password, verbose=self.verbose,
                                 headers=self.headers, verify=self.verify, cert=self.cert)

        # build XML request from parameters
        if request is None:
            requestElement = execution.buildRequest(identifier, inputs, output, mode=mode, lineage=lineage)
            request = etree.tostring(requestElement)
            execution.request = request
        log.debug(request)

        # submit the request to the live server
        if response is None:
            response = execution.submitRequest(request)
        else:
            response = etree.fromstring(response)

        log.debug(etree.tostring(response))

        # parse response
        execution.parseResponse(response)

        return execution
github ESGF / esgf-compute-api / cwt / wps.py View on Github external
# 
        if len(self.dataInputs) > 0:
            log.debug('clean data inputs')
            self.dataInputs[:] = []
        for inputElement in root.findall(nspath('DataInputs/Input', ns=wpsns)):
            self.dataInputs.append(Output(inputElement))
            if self.verbose is True:
                dump(self.dataInputs[-1])

        # 
        # xmlns:ns="http://www.opengis.net/wps/1.0.0"
        if len(self.processOutputs) > 0:
            log.debug('clean process outputs')
            self.processOutputs[:] = []
        for outputElement in root.findall(nspath('ProcessOutputs/Output', ns=wpsns)):
            self.processOutputs.append(Output(outputElement))
            if self.verbose is True:
                dump(self.processOutputs[-1])