Verified Commit 685013e4 authored by Cédric's avatar Cédric
Browse files

Python 3 compatibility.

parent f2216509
......@@ -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
......@@ -23,12 +23,12 @@ var latitude = null;
var longitude = null;
$(document).ready(function() {
resto = $.cookie("restaurant");
if (resto == "" || resto == undefined) {
previously_selected_restaurant = $.cookie("restaurant");
if (previously_selected_restaurant == "" || previously_selected_restaurant == undefined) {
getLocation();
}
else {
document.getElementById("restaurant_name").innerHTML = "Just go to " + resto + " !!!";
document.getElementById("restaurant_name").innerHTML = "Just go to " + previously_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();
},
......
......@@ -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()
......
python-3.4.2
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment