Skip to content

Commit

Permalink
🌟 style: fix code style issues with Black
Browse files Browse the repository at this point in the history
  • Loading branch information
GuniBot committed Nov 14, 2023
1 parent 27df5b9 commit 8036713
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions plugins/monitoring/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,25 @@ async def cog_load(self) -> None:
if await self.ping_monitoring():
self.logger.info("Monitoring test ping successful")
self.logger.info("Monitoring enabled")
self.loop.start() #pylint: disable=no-member
self.loop.start() # pylint: disable=no-member
return
self.logger.warning("Monitoring ping failed %s times", i + 1)
time.sleep(5)
self.bot.dispatch("error", RuntimeError("Monitoring disabled due to ping failure"))
self.bot.dispatch(
"error", RuntimeError("Monitoring disabled due to ping failure")
)

async def ping_monitoring(self):
# retrieve Discord Ping
ping = round(self.bot.latency * 1000, 0)

# build URL
url = (self.config["monitoring_push_url"] +
self.config["monitoring_push_monitor"] +
"?status=up&msg=OK&ping=" + str(ping))
url = (
self.config["monitoring_push_url"]
+ self.config["monitoring_push_monitor"]
+ "?status=up&msg=OK&ping="
+ str(ping)
)

# send request
async with self.session.get(url) as resp:
Expand All @@ -55,7 +60,9 @@ async def ping_monitoring(self):
json = await resp.json()
try:
if not json["ok"]:
self.logger.error("Monitoring ping failed with error : %s", json["msg"])
self.logger.error(
"Monitoring ping failed with error : %s", json["msg"]
)
return False
return True
except KeyError:
Expand All @@ -69,8 +76,11 @@ async def loop(self):
return
self.error_counter += 1
if self.error_counter >= 6:
self.bot.dispatch("error", RuntimeError("Monitoring disabled due to multiple ping failure"))
self.loop.stop() #pylint: disable=no-member
self.bot.dispatch(
"error",
RuntimeError("Monitoring disabled due to multiple ping failure"),
)
self.loop.stop() # pylint: disable=no-member

@loop.before_loop
async def before_ping_monitoring(self):
Expand Down

0 comments on commit 8036713

Please sign in to comment.