|
|
@ -21,21 +21,17 @@ class BackendClient: |
|
|
|
async def pulse(self, exit_if_error = False): |
|
|
|
async with aiohttp.ClientSession(cookies={ |
|
|
|
"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() |
|
|
|
self.up = True |
|
|
|
if not self.warn: |
|
|
|
info("Backend connected!") |
|
|
|
self.warn = True |
|
|
|
except: |
|
|
|
error("Backend not respond") |
|
|
|
traceback.print_exc() |
|
|
|
if exit_if_error: |
|
|
|
error("exit if backend is down") |
|
|
|
sys.exit(200) |
|
|
|
self.up = False |
|
|
|
self.warn = False |
|
|
|
except: |
|
|
|
error("Cannot create http session") |
|
|
|
if exit_if_error: |
|
|
|
error("exit if backend is down") |
|
|
|
sys.exit(200) |
|
|
|
self.up = False |
|
|
|
self.warn = False |
|
|
|
return self.up |
|
|
|
|
|
|
|
async def vip(self, steamid: SteamID, amount: int, extra: str, unique: str = ""): |
|
|
@ -61,11 +57,11 @@ class BackendClient: |
|
|
|
|
|
|
|
async def prices(self, exit_if_error = False): |
|
|
|
async with aiohttp.ClientSession() as session: |
|
|
|
async with session.get(self.vip_url) as response: |
|
|
|
try: |
|
|
|
return await response.json() |
|
|
|
except: |
|
|
|
traceback.print_exc() |
|
|
|
if exit_if_error: |
|
|
|
error("exit if cannot get prices") |
|
|
|
sys.exit(200) |
|
|
|
try: |
|
|
|
async with session.get(self.vip_url) as response: |
|
|
|
return await response.json() |
|
|
|
except: |
|
|
|
traceback.print_exc() |
|
|
|
if exit_if_error: |
|
|
|
error("exit if cannot get prices") |
|
|
|
sys.exit(200) |