From: Jakob Cornell Date: Mon, 4 Apr 2022 15:42:02 +0000 (-0500) Subject: Scrape tool: configure database connection from env X-Git-Url: https://jcornell.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=973fc60c40e1480d7fbb711ef1f783fedc6342fa;p=eros.git Scrape tool: configure database connection from env --- diff --git a/disk_jumble/src/disk_jumble/scrape.py b/disk_jumble/src/disk_jumble/scrape.py index 19542bc..d298bfd 100644 --- a/disk_jumble/src/disk_jumble/scrape.py +++ b/disk_jumble/src/disk_jumble/scrape.py @@ -68,8 +68,6 @@ def scrape_batch(tracker: Tracker, info_hashes: Iterable[bytes], passkey: str) - if __name__ == "__main__": - PSQL_PARAMS = ["dbname", "user", "password", "host", "port", "service"] - def tracker_name(val): matches = [n for n in TRACKERS.keys() if n.lower() == val.lower()] if matches: @@ -110,15 +108,11 @@ if __name__ == "__main__": help = "delay between batches, in seconds", ) - for arg_name in PSQL_PARAMS: - parser.add_argument("--" + arg_name, nargs = "?") - args = parser.parse_args() tracker = TRACKERS[args.tracker] delay = dt.timedelta(seconds = args.delay) - params = {n: getattr(args, n) for n in PSQL_PARAMS if getattr(args, n)} - with contextlib.closing(psycopg2.connect(**params)) as conn: + with contextlib.closing(psycopg2.connect("")) as conn: conn.autocommit = True db_wrapper = DbWrapper(conn) passkey = db_wrapper.get_passkey(tracker.gazelle_id)