summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alarmpy.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/alarmpy.py b/alarmpy.py
index d888330..8e531ef 100644
--- a/alarmpy.py
+++ b/alarmpy.py
@@ -29,10 +29,16 @@ class Alarm(object):
sleep(self.delay)
def fetch(self):
- res = requests.get(self.URL, headers=self.HEADERS, timeout=1)
now = datetime.now()
ts = now.strftime("%Y-%m-%d %H:%M:%S")
+ try:
+ res = requests.get(self.URL, headers=self.HEADERS, timeout=1)
+ except Exception as e:
+ click.secho(f"{ts} ", nl=False)
+ click.secho(f"Exception: {e}", fg="yellow")
+ return
+
if res.content:
click.secho(f"{ts} ", nl=False)
try: