[OWSLib-users] connection refused when searching a specific metadata

Chiarello Ernest Ernest.Chiarello at univ-fcomte.fr
Fri Apr 29 06:41:23 PDT 2016


Hello Tom,

pleased to meet you  !

Le 29/04/2016 14:17, Tom Kralidis a écrit :
> Hi Ernest:
>
> On Fri, Apr 29, 2016 at 5:49 AM, Ernest Chiarello
> <ernest.chiarello at univ-fcomte.fr> wrote:
>> Hello,
>>
>> i am new in this list and in Python, so it is possible that i ask naive
>> issues...
>> i am looking for a specific metadata in geonetwork, according to owslib
>> documentation.
>>
>> it works well with Chrome and Firefox, using this url:
>> http://geonetwork-mshe.univ-fcomte.fr:8080/geonetwork/srv/fre/catalog.search#/metadata/8174d16d-240f-4199-9c2f-af6976e376b3
>>
>> but i fails with owslib. :'(
>>
>>>>> geonetwork =
>>>>> 'http://geonetwork-mshe.univ-fcomte.fr:8080/geonetwork/srv/fre/csw'
>>>>> csw = CatalogueServiceWeb(geonetwork)
>>>>> csw.getrecordbyid(id=['8174d16d-240f-4199-9c2f-af6976e376b3'])
>> Traceback (most recent call last):
>>    File "<stdin>", line 1, in <module>
>>    File "/usr/lib/python2.7/dist-packages/owslib/csw.py", line 293, in
>> getrecordbyid
>>      self._invoke()
>>    File "/usr/lib/python2.7/dist-packages/owslib/csw.py", line 647, in
>> _invoke
>>      self.response = openURL(self.request, None, 'Get',
>> username=self.username, password=self.password, timeout=self.timeout).read()
>>    File "/usr/lib/python2.7/dist-packages/owslib/util.py", line 186, in
>> openURL
>>      **rkwargs)
>>    File "/usr/lib/python2.7/dist-packages/requests/api.py", line 53, in
>> request
>>      return session.request(method=method, url=url, **kwargs)
>>    File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 468, in
>> request
>>      resp = self.send(prep, **send_kwargs)
>>    File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 576, in
>> send
>>      r = adapter.send(request, **kwargs)
>>    File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 437, in
>> send
>>      raise ConnectionError(e, request=request)
>> requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost',
>> port=8080): Max retries exceeded with url:
>> /geonetwork/srv/fre/csw?outputFormat=application%2Fxml&service=CSW&outputSchema=http%3A%2F%2Fwww.opengis.net%2Fcat%2Fcsw%2F2.0.2&request=GetRecordById&version=2.0.2&elementsetname=full&id=8174d16d-240f-4199-9c2f-af6976e376b3
>> (Caused by
>> NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection
>> object at 0x7fd4f8050fd0>: Failed to establish a new connection: [Errno 111]
>> Connection refused',))
>>
>> any idea ?
>>
> I'm guessing the CSW you are querying has 'http://localhost:8080' set as it's
> host in the CSW configuration.  OWSLib's CSW support does a GetCapabilities
> request by default to get this information.  You can use the skip_caps=True
> parameter to bypass this:
>
> csw = CatalogueServiceWeb(geonetwork, skip_caps=True)

you are right, with this option, the request is successful.

 >>> geonetwork = 
'http://geonetwork-mshe.univ-fcomte.fr:8080/geonetwork/srv/fre/csw'
 >>> from owslib.csw import CatalogueServiceWeb
 >>> csw = CatalogueServiceWeb(geonetwork, skip_caps=True)
 >>> csw.getrecordbyid(id=['8174d16d-240f-4199-9c2f-af6976e376b3'])
 >>>
 >>> for rec in csw.records:
...     print csw.records[rec].title
...
Localities in Victoria (VMADMIN.LOCALITY_POLYGON) - Comprehensive Elements

it works also on our geOrchestra instance ! :-)

 >>> geonetwork = 
'https://georchestra-mshe.univ-fcomte.fr/geonetwork/srv/fre/csw'
 >>>
 >>>
 >>> georchestra = 
'https://georchestra-mshe.univ-fcomte.fr/geonetwork/srv/fre/csw'
 >>> from owslib.csw import CatalogueServiceWeb
 >>> csw = CatalogueServiceWeb(georchestra, skip_caps=True)
 >>> csw.getrecordbyid(id=['7253afc776baa4ed602def02e4ef04d15ef5ebd3'])
 >>> for rec in csw.records:
...     print csw.records[rec].title
...
voirie__voirie_pcn


>
> which means OWSLib will always use the URL you specify when initializing
> the CSW.  This is not always guaranteed to work as some CSW implementations
> have URLs which differ depending on the operation.

do you mean that it is possible to change that in geonetwork/csw 
configuration ?

> Having said this, the CSW itself should update its configuration accordingly
> to prevent this issue from manifesting itself for downstream
> clients/applications.
>
> Hope this helps.
Thanks a lot.

Ernest.
>
> ..Tom
>
>> Thanks in advance.
>>
>> Ernest.
>>


-- 
Ernest CHIARELLO  -  Ernest.Chiarello at univ-fcomte.fr
UMR6049 ThéMA - Théoriser et Modéliser pour Aménager
CNRS / université de Bourgogne Franche-Comté
32 rue Mégevand 25030 BESANÇON Cedex

Tel : 03 81 66 54 80           Mob : 07 82 99 11 08




More information about the OWSLib-users mailing list