commit bdb5337faa8ea07e9598f1885657716c8e695094
parent 436db61cc8e248be7f8607928256ff6f9a577524
Author: pyratebeard <root@pyratebeard.net>
Date: Fri, 30 Sep 2022 12:03:46 +0100
parse gcd creds from config file
Diffstat:
M | longbox | | | 25 | ++++++++++++++++++++----- |
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/longbox b/longbox
@@ -18,6 +18,7 @@ from prettytable import PrettyTable
import sqlite3
from sqlite3 import Error
import operator
+import configparser
#░ local database dir
def get_db_dir():
@@ -52,7 +53,7 @@ wishdb = os.path.join(dbpath, 'wishlist.db')
#░ local conf file
confpath = get_conf_dir()
mkdirs(confpath)
-boxrc = os.path.join(confpath, 'longboxrc')
+longboxrc = os.path.join(confpath, 'longboxrc')
#░ parse arguments
parser = argparse.ArgumentParser(description = "comic book stash manager")
@@ -104,6 +105,20 @@ if query:
if dateregexp.search(q):
search_date = q
+#░ parse config file
+config = configparser.ConfigParser()
+config.read(longboxrc)
+if 'gcd' in config:
+ gcdconf = config['gcd']
+ if 'user' in gcdconf:
+ gcduser = gcdconf['user']
+ else:
+ gcduser = input("gcd username: ")
+ if 'password' in gcdconf:
+ gcdpass = gcdconf['password']
+ else:
+ gcdpass = getpass("gcd password: ")
+
#░ build some mysql statements
#░ if we are searching with an issue number
if search_number:
@@ -228,8 +243,8 @@ def stash_connection(db_file):
try:
with connect(
host="localhost",
- user=input("username: "),
- password=getpass("password: "),
+ user=gcduser,
+ password=gcdpass,
database="gcd"
) as connection:
with connection.cursor() as cursor:
@@ -306,8 +321,8 @@ else:
try:
with connect(
host="localhost",
- user=input("username: "),
- password=getpass("password: "),
+ user=gcduser,
+ password=gcdpass,
database="gcd"
) as connection:
with connection.cursor() as cursor: