From 5e394ad7a66f2afd9d79921424b8f76534f5b4d6 Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Fri, 14 May 2021 11:10:14 +0300 Subject: Implement Github action CI workflow (#4) * Add pylint dependency * Add initial pylintrc and scripts * Cleanup lints * Initial CI workflow * Skip tests for now --- alarmpy.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'alarmpy.py') diff --git a/alarmpy.py b/alarmpy.py index 8817eef..497eabd 100644 --- a/alarmpy.py +++ b/alarmpy.py @@ -31,7 +31,7 @@ class Alarm(object): try: cities, alarm_id = self.fetch() self.update(cities, alarm_id) - except Exception as e: + except Exception as e: # pylint: disable=broad-except self.output_error(f"Exception: {e}") finally: sleep(self.delay) @@ -39,8 +39,8 @@ class Alarm(object): def fetch(self): try: res = requests.get(self.URL, headers=self.HEADERS, timeout=1) - except requests.Timeout: - raise Exception("HTTP request timed out") + except requests.Timeout as e: + raise Exception("HTTP request timed out") from e if not res.content: # empty content means no alarms @@ -51,10 +51,10 @@ class Alarm(object): alarm_id = data["id"] cities = data["data"] return cities, alarm_id - except ValueError: - raise Exception(f"Error parsing JSON: {res.content}") - except KeyError: - raise Exception(f"Missing keys in JSON data: {data}") + except ValueError as ve: + raise Exception(f"Error parsing JSON: {res.content}") from ve + except KeyError as ke: + raise Exception(f"Missing keys in JSON data: {data}") from ke def update(self, cities, alarm_id): if cities: @@ -88,7 +88,7 @@ class Alarm(object): def output_routine(self): self.output_leading_timestamp() - click.secho(f"No active alarms", fg="green") + click.secho("No active alarms", fg="green") def output_alarms(self, cities, alarm_id): self.output_leading_timestamp() -- cgit v1.3.1