<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<font face="Times New Roman, Times, serif"><big>Hi,<br>
<br>
thank you for your two responses. <br>
Thanks to Dom's message, we realized that this error was caused
by the version of OWSLib. With a Debian Jessie, the default
version of OWSLib is 0.8.10-1. We have forced the installation
of the latest version 0.11.2 (but we still use python 2.7) and
it's working right !<br>
<br>
Kind regards,<br>
</big><br>
</font>
<div class="moz-signature"><i>Sophie MOLLARD</i>
<br>
<br>
<i>Pôle Géomatique</i><br>
<i><a href="http://mshe.univ-fcomte.fr">MSHE C. N. Ledoux (USR
3124)</a></i><br>
<i>Université de Franche-Comté</i><br>
<i>Tél : 03.81.66.51.55</i><br>
<br>
</div>
<div class="moz-cite-prefix">Le 17/06/2016 04:32, Dominic Lowe a
écrit :<br>
</div>
<blockquote
cite="mid:f459d6264bc04936b28567f17f9f9508@iss-exch13-02.bom.gov.au"
type="cite">
<pre wrap="">Hi Sophie,
This is working for me too using Python 2.7.6 on Ubuntu, inserting into Geonetwork 3.0.3.0
I also have:
</pre>
<blockquote type="cite">
<pre wrap="">print sys.getdefaultencoding()
ascii
</pre>
</blockquote>
<pre wrap="">
This is using the latest version of OWSLib: 0.11.2.
Regards
Dom
-----Original Message-----
From: OWSLib-users [<a class="moz-txt-link-freetext" href="mailto:owslib-users-bounces@lists.osgeo.org">mailto:owslib-users-bounces@lists.osgeo.org</a>] On Behalf Of Tom Kralidis
Sent: Thursday, 16 June 2016 8:07 AM
To: Sophie Mollard
Cc: <a class="moz-txt-link-abbreviated" href="mailto:owslib-users@lists.osgeo.org">owslib-users@lists.osgeo.org</a>
Subject: Re: [OWSLib-users] OWSLib UnicodeEncodeError with accents
Hi Sophie: FYI I'm able to insert this metadata to a CSW using OWSLib without issue. You'll want to consult your CSW server to further debug.
..Tom
On Wed, Jun 8, 2016 at 8:28 AM, Sophie Mollard <a class="moz-txt-link-rfc2396E" href="mailto:sophie.mollard@mshe.univ-fcomte.fr"><sophie.mollard@mshe.univ-fcomte.fr></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi Tom,
Here is the metadata file attached.
Thank you,
Sophie MOLLARD
Pôle Géomatique
MSHE C. N. Ledoux (USR 3124)
Université de Franche-Comté
Tél : 03.81.66.51.55
Le 07/06/2016 20:56, Tom Kralidis a écrit :
Hi Sophie: can you post a test case/XML metadata so I can try to reproduce?
On Tue, Jun 7, 2016 at 10:39 AM, Sophie Mollard
<a class="moz-txt-link-rfc2396E" href="mailto:sophie.mollard@mshe.univ-fcomte.fr"><sophie.mollard@mshe.univ-fcomte.fr></a> wrote:
Hi list,
I'm using owslib to insert metadata files into GeoNetwork with a
python 2.7 script. It works fine except with metadatas which contain accents.
csw.transaction(ttype='insert', typename='gmd:MD_Metadata',
record=open('Haies_Franche_Comte_metadata.xml').read())
File "/usr/lib/python2.7/dist-packages/owslib/csw.py", line 432, in
transaction
self._invoke()
File "/usr/lib/python2.7/dist-packages/owslib/csw.py", line 635, in
_invoke
self.response = util.http_post(xml_post_url, self.request,
self.lang, self.timeout, self.username, self.password)
File "/usr/lib/python2.7/dist-packages/owslib/util.py", line 372, in
http_post
up = urllib2.urlopen(r,timeout=timeout);
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 449, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1227, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1194, in do_open
h.request(req.get_method(), req.get_selector(), req.data, headers)
File "/usr/lib/python2.7/httplib.py", line 1001, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 1035, in _send_request
self.endheaders(body)
File "/usr/lib/python2.7/httplib.py", line 997, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 854, in _send_output
self.send(message_body)
File "/usr/lib/python2.7/httplib.py", line 826, in send
self.sock.sendall(data)
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
position
1952: ordinal not in range(128)
I've written at the beginning of the script :
!/usr/bin/python
# -*-coding:Utf-8 -*
My metadata file is in utf-8 too :
georchestra-ouvert@georchestra-dev:~/bin/lib$ file -i
Haies_Franche_Comte_metadata.xml
Haies_Franche_Comte_metadata.xml: text/plain; charset=utf-8
However, my python environement is :
print sys.getdefaultencoding()
ascii
I've tried to change it in utf-8 but then, I've obtained this error
with owslib :
csw.transaction(ttype='insert', typename='gmd:MD_Metadata',
record=open('Haies_Franche_Comte_metadata.xml').read())
File "/usr/lib/python2.7/dist-packages/owslib/csw.py", line 432, in
transaction
self._invoke()
File "/usr/lib/python2.7/dist-packages/owslib/csw.py", line 635, in
_invoke
self.response = util.http_post(xml_post_url, self.request,
self.lang, self.timeout, self.username, self.password)
File "/usr/lib/python2.7/dist-packages/owslib/util.py", line 372, in
http_post
up = urllib2.urlopen(r,timeout=timeout);
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 437, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 550, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 475, in error
return self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 558, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 500: Erreur Interne de Servlet
What am I doing wrong ? Have you any idea ?
Thank you in advance,
--
Sophie MOLLARD
Pôle Géomatique
MSHE C. N. Ledoux (USR 3124)
Université de Franche-Comté
Tél : 03.81.66.51.55
_______________________________________________
OWSLib-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OWSLib-users@lists.osgeo.org">OWSLib-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/owslib-users">http://lists.osgeo.org/mailman/listinfo/owslib-users</a>
_______________________________________________
OWSLib-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OWSLib-users@lists.osgeo.org">OWSLib-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/owslib-users">http://lists.osgeo.org/mailman/listinfo/owslib-users</a>
</pre>
</blockquote>
<pre wrap="">_______________________________________________
OWSLib-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OWSLib-users@lists.osgeo.org">OWSLib-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/owslib-users">http://lists.osgeo.org/mailman/listinfo/owslib-users</a>
</pre>
</blockquote>
<br>
</body>
</html>