Browse Source

err fix

master
gsd 2 years ago
parent
commit
a9b854e0e3
  1. 34
      backend_integration.py

34
backend_integration.py

@ -20,20 +20,20 @@ class BackendClient:
async def pulse(self, exit_if_error = False): async def pulse(self, exit_if_error = False):
async with aiohttp.ClientSession(cookies={ async with aiohttp.ClientSession(cookies={
"secretkey":self.secret_key}) as session: "secretkey":self.secret_key}) as session:
async with session.get(self.pulse_url, ssl=False) as response: try:
try: async with session.get(self.pulse_url, ssl=False) as response:
await response.text() await response.text()
self.up = True self.up = True
if not self.warn: if not self.warn:
info("Backend connected!") info("Backend connected!")
self.warn = True self.warn = True
except: except:
error("Backend not respond") error("Backend not respond")
traceback.print_exc() traceback.print_exc()
if exit_if_error: if exit_if_error:
sys.exit(200) sys.exit(200)
self.up = False self.up = False
self.warn = False self.warn = False
return self.up return self.up
async def vip(self, steamid, amount: int, extra: str, unique: str = ""): async def vip(self, steamid, amount: int, extra: str, unique: str = ""):
@ -59,11 +59,11 @@ class BackendClient:
async def prices(self, exit_if_error = False): async def prices(self, exit_if_error = False):
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with session.get(self.vip_url) as response: try:
try: async with session.get(self.vip_url) as response:
return await response.json() return await response.json()
except: except:
traceback.print_exc() traceback.print_exc()
if exit_if_error: if exit_if_error:
error("Cannot fetch prices") error("Cannot fetch prices")
sys.exit(200) sys.exit(200)
Loading…
Cancel
Save