Merge pull request #52 from jlayec/fix-various

fix trip engine for hybrid cars + locale + get_vehicles url
This commit is contained in:
Florian BEZANNIER
2021-03-24 17:28:21 +01:00
committed by GitHub
3 changed files with 12 additions and 4 deletions
+4 -1
View File
@@ -32,7 +32,10 @@ class TripParser:
def get_hybrid_consumption(start, end):
res = []
for energy in [LEVEL, LEVEL_FUEL]:
res.append(start[energy] - end[energy])
if start[energy] is not None and end[energy] is not None:
res.append(start[energy] - end[energy])
else:
res.append(0)
return res
def __is_refuel_or_recharging(self, start, end, distance):
+1 -1
View File
@@ -25,7 +25,7 @@ def start_app(title, base_path, debug: bool, host, port):
lang = locale.getlocale()[0].split("_")[0]
locale.setlocale(locale.LC_TIME, ".".join(locale.getlocale())) #make sure LC_TIME is set
locale_url = [f"https://cdn.plot.ly/plotly-locale-{lang}-latest.js"]
except IndexError:
except (IndexError, locale.Error):
locale_url = None
logger.warning("Can't get language")
app = Flask(__name__)
+7 -2
View File
@@ -48,9 +48,14 @@ def display_value(value):
figures.battery_table, max_millis, step, marks
@app.route('/getvehicles')
@app.route('/get_vehicles')
def get_vehicules():
return jsonify(myp.get_vehicles())
response = app.response_class(
response=json.dumps(myp.get_vehicles(), default=lambda car: car.to_dict()),
status=200,
mimetype='application/json'
)
return response
@app.route('/get_vehicleinfo/<string:vin>')