handle missing URLs more gracefully
This commit is contained in:
parent
6ecb7c0430
commit
4e00328786
|
@ -114,24 +114,28 @@ def main(
|
|||
prev = None
|
||||
counter = itertools.count()
|
||||
while True:
|
||||
data = get_data(config.base_url)
|
||||
data = parse_data(data)
|
||||
summary = analyze_data(data)
|
||||
if summary != prev:
|
||||
if summary.sites:
|
||||
typer.echo(format_response(summary, format, next(counter)))
|
||||
if send_notification:
|
||||
try:
|
||||
subprocess.check_call(
|
||||
[
|
||||
"notify-send",
|
||||
appname,
|
||||
format_response(
|
||||
summary, AllowedFormat.json, next(counter)
|
||||
),
|
||||
]
|
||||
)
|
||||
except subprocess.CalledProcessError as e:
|
||||
typer.echo(e, err=True)
|
||||
prev = summary
|
||||
time.sleep(config.poll)
|
||||
try:
|
||||
data = get_data(config.base_url)
|
||||
data = parse_data(data)
|
||||
summary = analyze_data(data)
|
||||
if summary != prev:
|
||||
if summary.sites:
|
||||
typer.echo(format_response(summary, format, next(counter)))
|
||||
if send_notification:
|
||||
try:
|
||||
subprocess.check_call(
|
||||
[
|
||||
"notify-send",
|
||||
appname,
|
||||
format_response(
|
||||
summary, AllowedFormat.json, next(counter)
|
||||
),
|
||||
]
|
||||
)
|
||||
except subprocess.CalledProcessError as e:
|
||||
typer.echo(e, err=True)
|
||||
prev = summary
|
||||
except httpx.ConnectError as e:
|
||||
typer.echo(e, err=True)
|
||||
finally:
|
||||
time.sleep(config.poll)
|
||||
|
|
Loading…
Reference in New Issue