# paperdoorknob: Print glowfic # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, version 3. 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, session: requests.Session, timeout: int) -> None: with session.get(url, timeout=timeout) as r: r.raise_for_status() def main() -> None: args = command_line_parser().parse_args() with requests.session() as session: fetch(args.url, session, args.timeout) if __name__ == '__main__': main()