bug: fix not handling errors in send_graphql_query

This commit is contained in:
Upstream Data
2022-11-13 19:16:48 -07:00
parent cfa550f8c0
commit f0d8d66b9b

View File

@@ -68,20 +68,23 @@ class BOSMiner(BaseMiner):
async def send_graphql_query(self, query) -> Union[dict, None]: async def send_graphql_query(self, query) -> Union[dict, None]:
url = f"http://{self.ip}/graphql" url = f"http://{self.ip}/graphql"
async with httpx.AsyncClient() as client: try:
_auth = await client.post( async with httpx.AsyncClient() as client:
url, _auth = await client.post(
json={ url,
"query": 'mutation{auth{login(username:"' json={
+ self.uname "query": 'mutation{auth{login(username:"'
+ '", password:"' + self.uname
+ self.pwd + '", password:"'
+ '"){__typename}}}' + self.pwd
}, + '"){__typename}}}'
) },
d = await client.post(url, json={"query": query}) )
if d.status_code == 200: d = await client.post(url, json={"query": query})
return d.json() if d.status_code == 200:
return d.json()
except httpx.ReadError:
return None
return None return None
async def fault_light_on(self) -> bool: async def fault_light_on(self) -> bool: