X-Git-Url: http://git.scottworley.com/paperdoorknob/blobdiff_plain/92b11a100bc251b0b13d193b77f25b5f0bce08e7..680f7d1094d76ad090ce1f2c6ae3e14ca5d15677:/paperdoorknob.py diff --git a/paperdoorknob.py b/paperdoorknob.py index 8f1d840..cd93e4e 100644 --- a/paperdoorknob.py +++ b/paperdoorknob.py @@ -6,15 +6,27 @@ from argparse import ArgumentParser +import requests def command_line_parser() -> ArgumentParser: parser = ArgumentParser(prog='paperdoorknob', description='Print glowfic') + parser.add_argument( + '--timeout', + help='How long to wait for HTTP requests, in seconds', + default=30) + parser.add_argument('url', help='URL to retrieve') return parser +def fetch(url: str, timeout: int) -> None: + r = requests.get(url, timeout=timeout) + r.raise_for_status() + + def main() -> None: - command_line_parser().parse_args() + args = command_line_parser().parse_args() + fetch(args.url, args.timeout) if __name__ == '__main__':