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