Skip to content

Commit

Permalink
fix: compatible with the latest scql version
Browse files Browse the repository at this point in the history
  • Loading branch information
NewByVector committed Jul 26, 2024
1 parent f717644 commit 285015f
Showing 1 changed file with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ async def request(self, url: str, method="GET", body=None):
print("Error: " + str(e))

def get_request_status(self, response):
if response is None:
return 500, "no response found."

code = 0
message = ""
status = response.get("status", None)
Expand All @@ -70,7 +73,7 @@ async def create_project(self, project: Dict[str, Any], address: str) -> str:
)
code, message = self.get_request_status(response)

if code != 0:
if response is None or code != 0:
raise Exception(message)

return response.get("project_id", "")
Expand All @@ -85,7 +88,7 @@ async def get_project_list(self, address: str) -> List[Dict[str, Any]]:
)
code, message = self.get_request_status(response)

if code != 0:
if response is None or code != 0:
raise Exception(message)

return response.get("projects", [])
Expand All @@ -100,12 +103,12 @@ async def get_project_info(self, project_id: str, address: str) -> Dict[str, Any
)
code, message = self.get_request_status(response)

if code != 0:
if response is None or code != 0:
raise Exception(message)

project = response.get("projects", [])

return project[0] if len(project) > 0 else None
return project[0] if len(project) > 0 else None # type: ignore

async def get_invitation_list(
self, party: str, address: str
Expand All @@ -119,7 +122,7 @@ async def get_invitation_list(
)
code, message = self.get_request_status(response)

if code != 0:
if response is None or code != 0:
raise Exception(message)

invite_list = response.get("invitations", [])
Expand Down Expand Up @@ -177,7 +180,7 @@ async def get_table_list(
)
code, message = self.get_request_status(response)

if code != 0:
if response is None or code != 0:
raise Exception(message)

return response.get("tables", [])
Expand Down Expand Up @@ -230,7 +233,7 @@ async def get_table_info(
)
code, message = self.get_request_status(response)

if code != 0:
if response is None or code != 0:
raise Exception(message)

table = response.get("tables", [])
Expand All @@ -252,7 +255,7 @@ async def get_ccl_list(
)
code, message = self.get_request_status(response)

if code != 0:
if response is None or code != 0:
raise Exception(message)

return response.get("column_control_list", [])
Expand Down Expand Up @@ -304,12 +307,13 @@ async def query(self, project_id: str, query: str, address: str) -> List[Any]:
method="POST",
body=body,
)

code, message = self.get_request_status(response)

if code != 0:
if response is None or code != 0:
raise Exception(message)

return response.get("out_columns", [])
return response.get("result").get("out_columns", [])

async def create_query_job(self, project_id: str, address: str, query: str) -> str:
url = f"{address}{BROKER_SERVICE_PATH['submit_query']}"
Expand All @@ -324,7 +328,7 @@ async def create_query_job(self, project_id: str, address: str, query: str) -> s
)
code, message = self.get_request_status(response)

if code != 0:
if response is None or code != 0:
raise Exception(message)

return response.get("job_id", "")
Expand All @@ -339,7 +343,7 @@ async def get_job_result(self, job_id: str, address: str) -> List[Any]:
)
code, message = self.get_request_status(response)

if code != 0:
if response is None or code != 0:
raise Exception(message)

return response.get("out_columns", [])
Expand Down

0 comments on commit 285015f

Please sign in to comment.