Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Menu
Open sidebar
Cédric
cedric-onmange-ou
Commits
685013e4
Verified
Commit
685013e4
authored
May 22, 2015
by
Cédric
Browse files
Python 3 compatibility.
parent
f2216509
Changes
4
Hide whitespace changes
Inline
Side-by-side
refuge/conditions.py
View file @
685013e4
...
...
@@ -37,16 +37,16 @@ def rain():
try
:
result
=
requests
.
get
(
"http://api.openweathermap.org/data/2.5/weather?q=Luxembourg,Lux"
)
except
Exception
as
e
:
print
str
(
e
)
print
(
str
(
e
)
)
return
True
if
result
.
status_code
!=
200
:
print
result
.
status_code
print
(
result
.
status_code
)
return
True
json_result
=
json
.
loads
(
result
.
text
)
try
:
return
json_result
[
'weather'
][
0
][
'main'
]
!=
'Rain'
except
Exception
as
e
:
print
str
(
e
)
print
(
str
(
e
)
)
return
False
refuge/templates/restaurant.html
View file @
685013e4
...
...
@@ -23,12 +23,12 @@ var latitude = null;
var
longitude
=
null
;
$
(
document
).
ready
(
function
()
{
re
sto
=
$
.
cookie
(
"
restaurant
"
);
if
(
re
sto
==
""
||
re
sto
==
undefined
)
{
p
re
viously_selected_restaurant
=
$
.
cookie
(
"
restaurant
"
);
if
(
p
re
viously_selected_restaurant
==
""
||
p
re
viously_selected_restaurant
==
undefined
)
{
getLocation
();
}
else
{
document
.
getElementById
(
"
restaurant_name
"
).
innerHTML
=
"
Just go to
"
+
re
sto
+
"
!!!
"
;
document
.
getElementById
(
"
restaurant_name
"
).
innerHTML
=
"
Just go to
"
+
p
re
viously_selected_restaurant
+
"
!!!
"
;
};
})
...
...
@@ -62,7 +62,10 @@ function get_restaurant(latitude, longitude) {
document
.
getElementById
(
"
voice_button
"
).
onclick
=
function
()
{
speak
.
play
(
restaurant
[
"
name
"
]);
};
document
.
getElementById
(
"
voice_button
"
).
style
.
visibility
=
"
visible
"
;
$
.
cookie
(
"
restaurant
"
,
restaurant
[
"
name
"
]);
// store the selected restaurant in cookie which will expire at midnight
var
currentDate
=
new
Date
();
expirationDate
=
new
Date
(
currentDate
.
getFullYear
(),
currentDate
.
getMonth
(),
currentDate
.
getDate
()
+
1
,
0
,
0
,
0
);
$
.
cookie
(
"
restaurant
"
,
restaurant
[
"
name
"
],
{
expires
:
expirationDate
});
create_map
();
},
...
...
refuge/views.py
View file @
685013e4
...
...
@@ -7,8 +7,8 @@ import json
import
datetime
from
flask
import
render_template
,
jsonify
,
request
import
parking
import
conditions
from
.
import
parking
from
.
import
conditions
from
refuge
import
app
,
restaurants
,
jc_decaux_api_key
from
polyline.codec
import
PolylineCodec
...
...
@@ -46,7 +46,7 @@ def select_restaurant(method='GET', key=None, latitude=None, longitude=None):
restaurant
[
"coordinates"
][
"lat"
],
restaurant
[
"coordinates"
][
"long"
]))
if
r
.
status_code
==
200
:
result
=
json
.
loads
(
r
.
content
)
result
=
json
.
loads
(
r
.
content
.
decode
(
'utf-8'
)
)
if
result
[
"status"
]
!=
0
:
continue
...
...
@@ -57,7 +57,7 @@ def select_restaurant(method='GET', key=None, latitude=None, longitude=None):
shortest_path
=
PolylineCodec
().
decode
(
result
[
"route_geometry"
])
restaurants_not_far
.
append
(
restaurant
)
else
:
print
restaurant
[
"name"
]
+
" is to far."
print
(
restaurant
[
"name"
]
+
" is to far."
)
currently_available_restaurants
=
restaurants_not_far
...
...
@@ -112,7 +112,7 @@ def restaurant_json(latitude=None, longitude=None, key=None):
selected_restaurant
[
"coordinates"
][
"lat"
],
selected_restaurant
[
"coordinates"
][
"long"
]))
if
r
.
status_code
==
200
:
result
=
json
.
loads
(
r
.
content
)
result
=
json
.
loads
(
r
.
content
.
decode
(
'utf-8'
)
)
if
result
[
"status"
]
!=
0
:
return
selected_restaurant
# TODO
...
...
@@ -147,7 +147,7 @@ def list_restaurants():
try
:
result
=
requests
.
get
(
"https://api.jcdecaux.com/vls/v1/stations?contract=Luxembourg&apiKey="
+
jc_decaux_api_key
)
if
result
.
status_code
==
200
:
stations
=
json
.
loads
(
result
.
content
)
stations
=
json
.
loads
(
result
.
content
.
decode
(
'utf-8'
)
)
except
:
pass
parkings
=
parking
.
get_parkings
()
...
...
runtime.txt
0 → 100644
View file @
685013e4
python-3.4.2
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment