Use reqparser. Fix indentation.
This commit is contained in:
parent
df87a1deb8
commit
be8588d039
@ -184,15 +184,9 @@ class Set_mode_thermostat(Resource):
|
||||
@api.expect(Set_mode_parser, validate=True)
|
||||
def post(self):
|
||||
global new_forced_mode
|
||||
#try:
|
||||
# data = Set_mode(**request.json)
|
||||
#except Exception as e:
|
||||
# logging.error(e)
|
||||
# return "K0", 400
|
||||
try:
|
||||
args = Set_mode_parser.parse_args()
|
||||
new_forced_mode = args["value"]
|
||||
xprint(new_forced_mode)
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
return "K0", 400
|
||||
@ -203,7 +197,6 @@ class Status_thermostat(Resource):
|
||||
@auth_required
|
||||
def get(self):
|
||||
result = status_as_dict()
|
||||
logging.debug(result)
|
||||
return result
|
||||
|
||||
Set_verbosity_parser = api.parser()
|
||||
@ -216,13 +209,20 @@ class Set_verbosity_thermostat(Resource):
|
||||
@auth_required
|
||||
@api.expect(Set_verbosity_parser, validate=True)
|
||||
def put(self):
|
||||
if api.payload["value"] == 'DEBUG':
|
||||
try:
|
||||
args = Set_verbosity_parser.parse_args()
|
||||
if args["value"] == 'DEBUG':
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
elif api.payload["value"] == 'INFO':
|
||||
elif args["value"] == 'INFO':
|
||||
logging.getLogger().setLevel(logging.INFO)
|
||||
elif api.payload["value"] == 'WARNING':
|
||||
elif args["value"] == 'WARNING':
|
||||
logging.getLogger().setLevel(logging.WARNING)
|
||||
else:
|
||||
return "Bad request", 400
|
||||
return "OK", 201
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
return "K0", 400
|
||||
|
||||
api.add_namespace(ns_thermostat)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user