homecontrol: use f-strings
This commit is contained in:
parent
f673710c3e
commit
2c4c4bcd95
1 changed files with 6 additions and 6 deletions
|
@ -124,11 +124,11 @@ class Core:
|
||||||
try:
|
try:
|
||||||
q = self.db["actors"].find_one(actorId=actorId)
|
q = self.db["actors"].find_one(actorId=actorId)
|
||||||
ret["actorId"] = actorId
|
ret["actorId"] = actorId
|
||||||
ret["maxLevel"] = "0x%x" % q["maxLevel"]
|
ret["maxLevel"] = f"0x{q['maxLevel']}"
|
||||||
ret["actorType"] = q["actorType"]
|
ret["actorType"] = q["actorType"]
|
||||||
q = self.db["actor_levels"].find_one(actorId=actorId, order_by="-ts")
|
q = self.db["actor_levels"].find_one(actorId=actorId, order_by="-ts")
|
||||||
ret["ts"] = q["ts"]
|
ret["ts"] = q["ts"]
|
||||||
ret["level"] = "0x%x" % q["level"]
|
ret["level"] = f"0x{q['level']}"
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.logger.error("Exception Type:{type(ex).__name__}, args: {ex.args}")
|
self.logger.error("Exception Type:{type(ex).__name__}, args: {ex.args}")
|
||||||
return ret
|
return ret
|
||||||
|
@ -145,7 +145,7 @@ class Core:
|
||||||
query = self.db["actor_levels"].find(actorId=actorId)
|
query = self.db["actor_levels"].find(actorId=actorId)
|
||||||
levels = []
|
levels = []
|
||||||
for q in query:
|
for q in query:
|
||||||
levels.append({"ts": q["ts"], "value": "0x%x" % q["level"]})
|
levels.append({"ts": q["ts"], "value": f"0x{q['level']}"})
|
||||||
ret["levels"] = levels
|
ret["levels"] = levels
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.logger.error("Exception Type:{type(ex).__name__}, args: {ex.args}")
|
self.logger.error("Exception Type:{type(ex).__name__}, args: {ex.args}")
|
||||||
|
@ -252,7 +252,7 @@ def actor_get_level(actorId):
|
||||||
limit=int(request.args.get("limit"))
|
limit=int(request.args.get("limit"))
|
||||||
else:
|
else:
|
||||||
limit=None
|
limit=None
|
||||||
logger.debug("actor/get_levels/%s, limit: %s" % (actorId, limit))
|
logger.debug(f"actor/get_levels/{actorId}, limit: {limit}")
|
||||||
ret[actorId] = core.actor_get_levels(actorId, limit=limit)
|
ret[actorId] = core.actor_get_levels(actorId, limit=limit)
|
||||||
return make_response(jsonify(ret), 200)
|
return make_response(jsonify(ret), 200)
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ def sensor_get_values(sensorId):
|
||||||
limit=int(request.args.get("limit"))
|
limit=int(request.args.get("limit"))
|
||||||
if request.args.get("max_ts"):
|
if request.args.get("max_ts"):
|
||||||
max_ts=int(request.args.get("max_ts"))
|
max_ts=int(request.args.get("max_ts"))
|
||||||
logger.debug("sensor/get_values/%s, [%f, %f], limit: %s" % (sensorId, min_ts, max_ts, limit))
|
logger.debug(f"sensor/get_values/{sensorId}, [{min_ts}, {max_ts}], limit: {limit}")
|
||||||
ret[sensorId] = core.sensor_get_values(sensorId, min_ts=min_ts, max_ts=max_ts, limit=limit)
|
ret[sensorId] = core.sensor_get_values(sensorId, min_ts=min_ts, max_ts=max_ts, limit=limit)
|
||||||
return make_response(jsonify(ret), 200)
|
return make_response(jsonify(ret), 200)
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ def sensor_add_value():
|
||||||
value = content.get("value")
|
value = content.get("value")
|
||||||
ret = core.sensor_add_value(sensorId, sensorType, value)
|
ret = core.sensor_add_value(sensorId, sensorType, value)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logger.error('Exception Type:%s, args:\n%s' % (type(ex).__name__, ex.args))
|
logger.error("Exception Type:{type(ex).__name__}, args: {ex.args}")
|
||||||
abort(400)
|
abort(400)
|
||||||
return make_response(jsonify(ret), 200)
|
return make_response(jsonify(ret), 200)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue