[OWSLib-users] CatalogueServiceWeb and data.gov exception

Passmore, James H. jpass at bgs.ac.uk
Fri Jun 2 01:48:20 PDT 2017


The line

csw = CatalogueServiceWeb('http://catalog.data.gov/csw?service=CSW&version=2.0.2&request=GetCapabilities')

should be:

csw = CatalogueServiceWeb('http://catalog.data.gov/csw')

or (as you're getting redirected to an https service):

csw = CatalogueServiceWeb('https://catalog.data.gov/csw')

If I use (Python 3.6):

from owslib import csw as csw

c = csw.CatalogueServiceWeb('https://catalog.data.gov/csw')
c.getrecords2(maxrecords=20)
print(c.records)

I get a result (eventually ~ the service seems quite slow).

I've tried running a query but it seems to be taking forever to return

James

From: OWSLib-users [mailto:owslib-users-bounces at lists.osgeo.org] On Behalf Of Davide Muraro
Sent: 01 June 2017 12:44
To: owslib-users at lists.osgeo.org
Subject: [OWSLib-users] CatalogueServiceWeb and data.gov exception


Dear All,



I was doing some tests using CatalogueServiceWeb and the data.gov CSW.



Basically doing something like:


from owslib.csw import CatalogueServiceWeb
from owslib.fes import PropertyIsEqualTo, PropertyIsLike, BBox
csw = CatalogueServiceWeb('http://catalog.data.gov/csw?service=CSW&version=2.0.2&request=GetCapabilities')
query = PropertyIsEqualTo('csw:AnyText', 'map')
csw.getrecords2(constraints=[query], maxrecords=20)
print(csw.records)

i got:

*python3.5/site-packages/owslib/csw.py in getrecords2(self, constraints, sortby, typenames, esn, outputschema, format, startposition, maxrecords, cql, xml, resulttype)
    380
    381             # process search results attributes
--> 382             val = self._exml.find(util.nspath_eval('csw:SearchResults', namespaces)).attrib.get('numberOfRecordsMatched')
    383             self.results['matches'] = int(util.testXMLValue(val, True))
    384             val = self._exml.find(util.nspath_eval('csw:SearchResults', namespaces)).attrib.get('numberOfRecordsReturned')

AttributeError: 'NoneType' object has no attribute 'attrib'


Ideas?

D


________________________________
This message (and any attachments) is for the recipient only. NERC is subject to the Freedom of Information Act 2000 and the contents of this email and any reply you make may be disclosed by NERC unless it is exempt from release under the Act. Any material supplied to NERC may be stored in an electronic records management system.
________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/owslib-users/attachments/20170602/38bbebcf/attachment-0001.html>


More information about the OWSLib-users mailing list