[OWSLib-users] CatalogueServiceWeb and data.gov exception

Signell, Richard rsignell at usgs.gov
Sun Jun 4 14:25:45 PDT 2017


Davide,
I should have added that this is not really an OWSlib problem per se
because this is set by the CSW server (pycsw) configuration, but it
would be nice if OWSlib provided a function that would let the user
get around this easily.

You are in good company, BTW.   This has burned nearly every CSW user
I've come across ...  ;-(

-Rich

On Sun, Jun 4, 2017 at 5:22 PM, Signell, Richard <rsignell at usgs.gov> wrote:
> Davide
>
>> it works like a charm.
>
> Actually, not quite.  Did you notice you asked for 20 records and only
> get 10 back?
>
> It's annoying, but with OWSlib "getrecords" or "getrecords2", no
> matter what your maxrecords is, you will only get 10 back.
>
> So you need to iterate like this:
>
> http://nbviewer.jupyter.org/gist/rsignell-usgs/ade82853eebb2f0c16f222f0c57d94b2
>
> -Rich
>
>>
>> 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.
>> ________________________________
>>
>> _______________________________________________
>> OWSLib-users mailing list
>> OWSLib-users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/owslib-users
>
>
>
>
> --
> Dr. Richard P. Signell   (508) 457-2229
> USGS, 384 Woods Hole Rd.
> Woods Hole, MA 02543-1598



-- 
Dr. Richard P. Signell   (508) 457-2229
USGS, 384 Woods Hole Rd.
Woods Hole, MA 02543-1598


More information about the OWSLib-users mailing list