<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 Tom,<br>
<br>
Here is the metadata file attached.<br>
<br>
Thank you,<br>
</big></font><br>
<br>
<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 07/06/2016 20:56, Tom Kralidis a
écrit :<br>
</div>
<blockquote
cite="mid:CAFWXLWXOkA0x8VcOvFcuccQDaT7TNePLqJTKpbtfP8EN6A8jRw@mail.gmail.com"
type="cite">
<pre wrap="">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:
</pre>
<blockquote type="cite">
<pre wrap="">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>
</pre>
</blockquote>
</blockquote>
<br>
</body>
</html>