Skip to content

Commit

Permalink
add safelogin
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowbean committed Jul 23, 2023
1 parent d497516 commit b19109c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions absbox/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import json, datetime, pickle, re, urllib3
import json, datetime, pickle, re, urllib3, getpass
from importlib.metadata import version
from json.decoder import JSONDecodeError
from dataclasses import dataclass,field
Expand Down Expand Up @@ -193,7 +193,13 @@ def loginLibrary(self, user, pw, **q):
else:
console.print(f"❌[bold red]Failed to login")
return None


def safeLogin(self, user, **q):
try:
pw = getpass.getpass()
self.loginLibrary(user, pw, **q)
except Exception as e:
console.print(f"❌[bold red]{e}")

def queryLibrary(self,ks,**q):
if not hasattr(self,"token"):
Expand Down Expand Up @@ -241,7 +247,6 @@ def lookupReader(x):
case _:
raise RuntimeError(f"Failed to match reader:{x}")
try:
#_result = json.loads(result)
ri = result['run_info']
result = result['run_result']
console.print(f"✅[bold green]run success with deal id={ri['deal_id']}/report num={ri['report_num']},doc_id={ri['doc_id']}")
Expand Down

0 comments on commit b19109c

Please sign in to comment.