Skip to content

Commit

Permalink
add resp in query/run on deal library
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowbean committed Jul 15, 2023
1 parent ea0294f commit 2b583c3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions absbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def loginLibrary(self, user, pw, **q):
cred = {"user":user,"password":pw}
r = self._send_req(json.dumps(cred), deal_library_url)
if 'token' in r:
console.print(f"✅[bold green],login successfully")
console.print(f"✅[bold green] login successfully")
self.token = r['token']
else:
console.print(f"❌[bold red]Failed to login")
Expand All @@ -200,6 +200,8 @@ def queryLibrary(self,ks,**q):
d = {"bond_id": [k for k in ks] }
q = {"read":True} | q
result = self._send_req(json.dumps(d), deal_library_url,headers= {"Authorization":f"Bearer {self.token}"})

console.print(f"✅[bold green] query success")
if q['read'] == True:
if 'data' in result:
return pd.DataFrame(result['data'],columns=result['header'])
Expand All @@ -219,7 +221,8 @@ def runLibrary(self,_id,**p):
try:
result = json.loads(result)
except Exception as e:
console.print(f"error parsing resp from engine:{result}")
console.print(f"❌[bold red]message from API server:{result}")
console.print(f"❌[bold red]{e}")
def lookupReader(x):
match x:
case "china.SPV":
Expand All @@ -229,6 +232,7 @@ def lookupReader(x):
case _:
raise RuntimeError(f"Failed to match reader:{x}")

console.print(f"✅[bold green],run success")
classReader = lookupReader(p['reader'])
if read and isinstance(result,list):
return classReader.read(result)
Expand Down

0 comments on commit 2b583c3

Please sign in to comment.