diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-06-29 00:34:47 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2023-06-29 22:14:45 +0200 |
commit | 02feb335c0f8b01c0ee14d493f86f7f9e49c1bf9 (patch) | |
tree | 18ad01da91d69dca0690dc548f14b5ce512522eb | |
parent | 05a86f6587fce4c465e7e35b4b8d1cd6a2a9f30c (diff) | |
download | wee-slack-02feb335c0f8b01c0ee14d493f86f7f9e49c1bf9.tar.gz |
Fix usage of potentially unbound variables
-rwxr-xr-x | extract_token_from_browser.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/extract_token_from_browser.py b/extract_token_from_browser.py index b6b771b..9795605 100755 --- a/extract_token_from_browser.py +++ b/extract_token_from_browser.py @@ -115,6 +115,7 @@ else: cookies_path = default_profile_path.joinpath("Cookies") leveldb_path = default_profile_path.joinpath("Local Storage/leveldb") +con = None cookie_d_value = None cookie_ds_value = None try: @@ -126,7 +127,8 @@ except TypeError: print("Couldn't find the 'd' cookie value", file=sys.stderr) sys.exit(1) finally: - con.close() + if con: + con.close() if args.browser in ["chrome", "chrome-beta"]: bus = secretstorage.dbus_init() @@ -166,6 +168,7 @@ else: local_storage_path = default_profile_path.joinpath("webappsstore.sqlite") local_storage_query = "SELECT value FROM webappsstore2 WHERE key = 'localConfig_v2'" teams = [] +con = None local_config = None try: con = sqlite3.connect(f"file:{local_storage_path}?immutable=1", uri=True) @@ -182,7 +185,8 @@ except (OperationalError, TypeError): ) sys.exit(1) finally: - con.close() + if con: + con.close() if not local_config and leveldb_path: try: |