[OWSLib-users] CatalogueServiceWeb and data.gov exception

Davide Muraro muraro_davide at hotmail.com
Fri Jun 2 22:23:45 PDT 2017


Thanks  James!


from owslib.csw import CatalogueServiceWeb

from owslib.fes import PropertyIsEqualTo, PropertyIsLike, BBox


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

query = PropertyIsEqualTo('csw:AnyText', 'Africa')

csw.getrecords2(constraints=[query], maxrecords=20)

print(csw.records)

it works like a charm.

Davide

________________________________
Da: Passmore, James H. <jpass at bgs.ac.uk>
Inviato: venerdì 2 giugno 2017 10.48
A: Davide Muraro; owslib-users at lists.osgeo.org
Oggetto: RE: CatalogueServiceWeb and data.gov exception


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/20170603/208d8639/attachment.html>


More information about the OWSLib-users mailing list