Browse Source

fix(commands:iplocalise|Network): close TUXBOT-BOT-4N

master
Romain J 7 months ago
parent
commit
fd0600b75d
  1. 1
      .pylintrc
  2. 15
      tuxbot/cogs/Network/functions/utils.py
  3. BIN
      tuxbot/cogs/Network/images/load_fail.png
  4. 1
      tuxbot/cogs/Network/images/load_fail.py

1
.pylintrc

@ -12,6 +12,7 @@ disable=
C0114, # missing-module-docstring
C0115, # missing-class-docstring
C0116, # missing-function-docstring
C0415, # import-outside-toplevel
W0703, # broad-except
W0707, # raise-missing-from
R0801, # duplicate-code

15
tuxbot/cogs/Network/functions/utils.py

@ -229,12 +229,17 @@ async def get_map_bytes(apikey: str, latlon: str) -> Optional[io.BytesIO]:
url = url.format(lonlat=lonlat, apikey=apikey)
async with aiohttp.ClientSession() as cs:
async with cs.get(url) as s:
if s.status != 200:
return None
try:
async with aiohttp.ClientSession() as cs:
async with cs.get(url) as s:
if s.status != 200:
return None
return io.BytesIO(await s.read())
except asyncio.exceptions.TimeoutError:
from ..images.load_fail import value
return io.BytesIO(await s.read())
return io.BytesIO(value)
@cached(

BIN
tuxbot/cogs/Network/images/load_fail.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

1
tuxbot/cogs/Network/images/load_fail.py

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save