Commit 19b2596b4a4bbec03660394504f82e1ebb4cb257

Authored by Michel Gangloff
1 parent 3c6cda68
Exists in master

Correction erreur encodage

Showing 2 changed files with 23 additions and 16 deletions   Show diff stats
flask_app/app/main.py
  1 +# coding: utf8
1 2 from __future__ import print_function
  3 +from __future__ import unicode_literals
2 4  
3 5 import datetime
4 6 import os
  7 +import io
5 8  
6 9 import pytz
7 10 import voeventparse as vp
... ... @@ -64,8 +67,12 @@ def index():
64 67 # one dictionary for all field description
65 68 my_list_description = {"what":request.form['description']}
66 69  
  70 + my_shortname=request.form['shortname']
  71 + my_shortname=my_shortname.encode('utf-8')
  72 + print (my_shortname)
  73 +
67 74 output_filename = '/var/tmp/new_voevent.xml'
68   - new_voevent = open(output_filename,'w')
  75 + new_voevent = io.open(output_filename,'w',encoding='utf8')
69 76 new_voevent.write(template.render(voevent_id=voevent_id,
70 77 my_shortname=request.form['shortname'],
71 78 my_contactname=request.form['observer'],
... ... @@ -134,7 +141,7 @@ def indexlunar():
134 141 my_list_description = {"what":request.form['description']}
135 142  
136 143 output_filename = '/var/tmp/new_voevent.xml'
137   - new_voevent = open(output_filename,'w')
  144 + new_voevent = io.open(output_filename,'w',encoding='utf8')
138 145 new_voevent.write(template.render(voevent_id=voevent_id,
139 146 my_shortname=request.form['shortname'],
140 147 my_contactname=request.form['observer'],
... ... @@ -198,7 +205,7 @@ def indexcomet():
198 205 my_list_description = {"what":"Tail disconnection of comet 67P"}
199 206  
200 207 output_filename = '/var/tmp/new_voevent.xml'
201   - new_voevent = open(output_filename,'w')
  208 + new_voevent = io.open(output_filename,'w',encoding='utf8')
202 209 new_voevent.write(template.render(voevent_id=voevent_id,
203 210 my_shortname=request.form['shortname'],
204 211 my_contactname=request.form['observer'],
... ...
flask_app/app/new_voevent.xml
1 1 <?xml version="1.0" encoding="UTF-8"?>
2   -<voe:VOEvent ivorn="ivo://vopdc.obspm/VOEvent/#01604fa2-6b43-467b-aa51-861c54eff5c7"
  2 +<voe:VOEvent ivorn="ivo://vopdc.obspm/VOEvent/#b36903b4-b210-4a73-b303-76eba15a5ed2"
3 3 role="test" version="2.0"
4 4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5 5 xmlns:voe="http://www.ivoa.net/xml/VOEvent/v2.0"
... ... @@ -7,8 +7,8 @@
7 7 <Who>
8 8 <AuthorIVORN>ivo://psws/not_registered_yet</AuthorIVORN>
9 9 <Author>
10   - <shortName>MG</shortName>
11   - <contactName>Michel GANGLOFF</contactName>
  10 + <shortName>Mé</shortName>
  11 + <contactName>Mémé</contactName>
12 12 <contactPhone>604086971</contactPhone>
13 13 <contactEmail>Michel.Gangloff@yahoo.fr</contactEmail>
14 14 </Author>
... ... @@ -16,22 +16,22 @@
16 16 </Who>
17 17 <What>
18 18 <Description>
19   - Location of observation : Toulouse,France
20   - M
  19 + Location of observation : ré,aé
  20 + aéèç
21 21 </Description>
22 22 <Param name="event_status" value="finished" dataType="string" ucd="meta.flag" />
23   - <Param name="event_type" value="giant planet fireball" dataType="string" ucd="meta.flag" />
  23 + <Param name="event_type" value="detection" dataType="string" ucd="meta.flag" />
24 24 <Group name="target">
25   - <Param name="target_name" value="Jupiter" dataType="string" ucd="meta.id" />
26   - <Param name="target_class" value="planet" dataType="string" ucd="meta.id" />
27   - <Param name="target_region" value="atmosphere" dataType="string" ucd="meta.id" />
  25 + <Param name="target_name" value="Moon" dataType="string" ucd="meta.id" />
  26 + <Param name="target_class" value="satellite" dataType="string" ucd="meta.id" />
  27 + <Param name="target_region" value="surface" dataType="string" ucd="meta.id" />
28 28 <Param name="latitude" value="0" dataType="float" ucd="pos.bodyrc.lat" unit="deg" />
29 29 <Param name="longitude" value="0" dataType="float" ucd="pos.bodyrc.lon" unit="deg" />
30 30 </Group>
31 31 <Group name="source">
32   - <Param name="target_name" value="0" dataType="string" ucd="meta.id" />
33   - <Param name="target_class" value="comet" dataType="string" ucd="meta.id" />
34   - <Param name="target_region" value="trail" dataType="string" ucd="meta.id" />
  32 + <Param name="target_name" value="éç" dataType="string" ucd="meta.id" />
  33 + <Param name="target_class" value="asteroid" dataType="string" ucd="meta.id" />
  34 + <Param name="target_subclass" value="neo" dataType="string" ucd="meta.id" />
35 35 </Group>
36 36 </What>
37 37 <WhereWhen>
... ... @@ -54,7 +54,7 @@
54 54 </WhereWhen>
55 55 <How>
56 56 <Description>
57   - 0
  57 + ç
58 58 </Description>
59 59 <Reference uri="https://TBD.html" type="url" />
60 60 </How>
... ...