This repository has been archived on 2024-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
Bebop/bebop/__main__.py

35 lines
884 B
Python
Raw Normal View History

2021-02-12 19:01:42 +01:00
import argparse
2021-03-28 18:28:35 +02:00
from bebop.browser.browser import Browser
from bebop.config import load_config
from bebop.fs import get_config_path, get_user_data_path
2021-03-13 16:33:04 +01:00
from bebop.tofu import load_cert_stash, save_cert_stash
2021-02-12 19:01:42 +01:00
def main():
argparser = argparse.ArgumentParser()
2021-04-16 19:30:14 +02:00
argparser.add_argument("url", nargs="?", default=None)
2021-02-12 19:01:42 +01:00
args = argparser.parse_args()
if args.url:
start_url = args.url
else:
start_url = None
config_path = get_config_path()
config = load_config(config_path)
2021-03-13 16:33:04 +01:00
user_data_path = get_user_data_path()
if not user_data_path.exists():
user_data_path.mkdir()
cert_stash_path = user_data_path / "known_hosts.txt"
2021-03-28 18:28:54 +02:00
cert_stash = load_cert_stash(cert_stash_path) or {}
2021-03-13 16:33:04 +01:00
try:
Browser(config, cert_stash).run(start_url=start_url)
2021-03-13 16:33:04 +01:00
finally:
save_cert_stash(cert_stash, cert_stash_path)
2021-02-12 19:01:42 +01:00
main()