Scrape tool: configure database connection from env
authorJakob Cornell <jakob+gpg@jcornell.net>
Mon, 4 Apr 2022 15:42:02 +0000 (10:42 -0500)
committerJakob Cornell <jakob+gpg@jcornell.net>
Mon, 4 Apr 2022 15:42:02 +0000 (10:42 -0500)
disk_jumble/src/disk_jumble/scrape.py

index 19542bc36c0fa0bcdb5bfee45603e47a65c5b332..d298bfd14f7739887fd2abc47543f9676a05467f 100644 (file)
@@ -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)