fixed error result values in python api
This commit is contained in:
parent
504131c239
commit
6d4392c1bc
@ -15,12 +15,14 @@ def GetBerths(token):
|
|||||||
try:
|
try:
|
||||||
|
|
||||||
commands = pydapper.using(local_db.connection_pool)
|
commands = pydapper.using(local_db.connection_pool)
|
||||||
data = commands.query("SELECT id, name, participant_id, `lock`, created, modified FROM berth ORDER BY name", model=model.Berth)
|
data = commands.query("SELECT id, name, participant_id, `lock`, created, modified FROM berth ORDER BY name", model=model.Berth)
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
print(ex)
|
print(ex)
|
||||||
return json.dumps("call failed"), 500
|
result = {}
|
||||||
|
result["message"] = "call failed"
|
||||||
|
return json.dumps(result), 500
|
||||||
|
|
||||||
return json.dumps(data, default=model.obj_dict), 200
|
return json.dumps(data, default=model.obj_dict), 200
|
||||||
|
|
||||||
|
|||||||
@ -32,14 +32,20 @@ def GetUser(options):
|
|||||||
return json.dumps(result), 200
|
return json.dumps(result), 200
|
||||||
|
|
||||||
if len(data) > 1:
|
if len(data) > 1:
|
||||||
return json.dumps("credential lookup mismatch"), 500
|
result = {}
|
||||||
|
result["message"] = "credential lookup mismatch"
|
||||||
|
return json.dumps(result), 500
|
||||||
|
|
||||||
return json.dumps("invalid credentials"), 403
|
result = {}
|
||||||
|
result["message"] = "invalid credentials"
|
||||||
|
return json.dumps(result), 403
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
print(ex)
|
print(ex)
|
||||||
return json.dumps("call failed"), 500
|
result = {}
|
||||||
|
result["message"] = "call failed: " + str(ex)
|
||||||
|
return json.dumps(result), 500
|
||||||
|
|
||||||
# $2b$12$uWLE0r32IrtCV30WkMbVwOdltgeibymZyYAf4ZnQb2Bip8hrkGGwG
|
# $2b$12$uWLE0r32IrtCV30WkMbVwOdltgeibymZyYAf4ZnQb2Bip8hrkGGwG
|
||||||
# $2b$12$.vEapj9xU8z0RK0IpIGeYuRIl0ktdMt4XdJQBhVn.3K2hmvm7qD3y
|
# $2b$12$.vEapj9xU8z0RK0IpIGeYuRIl0ktdMt4XdJQBhVn.3K2hmvm7qD3y
|
||||||
|
|||||||
@ -23,6 +23,8 @@ def GetParticipant(options):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
print(ex)
|
print(ex)
|
||||||
|
result = {}
|
||||||
|
result["message"] = "call failed"
|
||||||
return json.dumps("call failed"), 500
|
return json.dumps("call failed"), 500
|
||||||
|
|
||||||
return json.dumps(data, default=model.obj_dict), 200
|
return json.dumps(data, default=model.obj_dict), 200
|
||||||
|
|||||||
@ -24,7 +24,9 @@ def GetShipcalls(options):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
print(ex)
|
print(ex)
|
||||||
return json.dumps("call failed"), 500
|
result = {}
|
||||||
|
result["message"] = "call failed"
|
||||||
|
return json.dumps(result), 500
|
||||||
|
|
||||||
return json.dumps(data, default=model.obj_dict), 200
|
return json.dumps(data, default=model.obj_dict), 200
|
||||||
|
|
||||||
@ -69,7 +71,9 @@ def PostShipcalls(schemaModel):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
print(ex)
|
print(ex)
|
||||||
return json.dumps("call failed"), 500
|
result = {}
|
||||||
|
result["message"] = "call failed"
|
||||||
|
return json.dumps(result), 500
|
||||||
|
|
||||||
|
|
||||||
def PutShipcalls(schemaModel):
|
def PutShipcalls(schemaModel):
|
||||||
@ -104,7 +108,9 @@ def PutShipcalls(schemaModel):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
print(ex)
|
print(ex)
|
||||||
return json.dumps("call failed"), 500
|
result = {}
|
||||||
|
result["message"] = "call failed"
|
||||||
|
return json.dumps(result), 500
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,9 @@ def GetShips(token):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
print(ex)
|
print(ex)
|
||||||
return json.dumps("call failed"), 500
|
result = {}
|
||||||
|
result["message"] = "call failed"
|
||||||
|
return json.dumps(result), 500
|
||||||
|
|
||||||
return json.dumps(data, default=model.obj_dict), 200
|
return json.dumps(data, default=model.obj_dict), 200
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,9 @@ def GetTimes(options):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
print(ex)
|
print(ex)
|
||||||
return json.dumps("call failed"), 500
|
result = {}
|
||||||
|
result["message"] = "call failed"
|
||||||
|
return json.dumps(result), 500
|
||||||
|
|
||||||
return json.dumps(data, default=model.obj_dict), 200
|
return json.dumps(data, default=model.obj_dict), 200
|
||||||
|
|
||||||
@ -68,7 +70,9 @@ def PostTimes(schemaModel):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
print(ex)
|
print(ex)
|
||||||
return json.dumps("call failed"), 500
|
result = {}
|
||||||
|
result["message"] = "call failed"
|
||||||
|
return json.dumps(result), 500
|
||||||
|
|
||||||
|
|
||||||
def PutTimes(schemaModel):
|
def PutTimes(schemaModel):
|
||||||
@ -103,7 +107,9 @@ def PutTimes(schemaModel):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
print(ex)
|
print(ex)
|
||||||
return json.dumps("call failed"), 500
|
result = {}
|
||||||
|
result["message"] = "call failed"
|
||||||
|
return json.dumps(result), 500
|
||||||
|
|
||||||
def DeleteTimes(options):
|
def DeleteTimes(options):
|
||||||
"""
|
"""
|
||||||
@ -118,9 +124,13 @@ def DeleteTimes(options):
|
|||||||
if affected_rows == 1:
|
if affected_rows == 1:
|
||||||
return json.dumps({"id" : options["id"]}), 200
|
return json.dumps({"id" : options["id"]}), 200
|
||||||
|
|
||||||
return json.dumps("no such record"), 404
|
result = {}
|
||||||
|
result["message"] = "no such record"
|
||||||
|
return json.dumps(result), 404
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
print(ex)
|
print(ex)
|
||||||
return json.dumps("call failed"), 500
|
result = {}
|
||||||
|
result["message"] = "call failed"
|
||||||
|
return json.dumps(result), 500
|
||||||
Loading…
Reference in New Issue
Block a user