Factor out REG_FILE

pull/4/head
Darksider3 5 years ago
parent 77efb4b339
commit cdc72a30f4

@ -4,7 +4,8 @@ import os
import lib.UserExceptions
def ImportFromFile(fname: str = CFG.args.file, db: str = CFG.REG_FILE, userids: tuple = tuple([])):
def ImportFromFile(fname: str = CFG.args.file, db: str = CFG.config['DEFAULT']['applications_db'],
userids: tuple = tuple([])):
if not os.path.isfile(fname):
print(f"File {fname} don't exist")
return None
@ -24,7 +25,7 @@ def ImportFromFile(fname: str = CFG.args.file, db: str = CFG.REG_FILE, userids:
import lib.sqlitedb
import lib.System
sysctl = lib.System.System()
sql = lib.sqlitedb.SQLitedb(CFG.REG_FILE)
sql = lib.sqlitedb.SQLitedb(CFG.config['DEFAULT']['applications_db'])
reader = csv.DictReader(f) # @TODO csv.Sniffer to compare? When yes, give force-accept option
for row in reader:
if row["status"] == "1":

@ -9,7 +9,7 @@ class ListUsers:
usersFetch = None
def __init__(self, uap: bool = CFG.args.unapproved, app: bool = CFG.args.approved):
self.db = SQLitedb(CFG.REG_FILE)
self.db = SQLitedb(CFG.config['DEFAULT']['applications_db'])
if uap: # only unapproved users
query = "SELECT * FROM `applications` WHERE status = '0'"
elif app: # Approved users

@ -8,5 +8,4 @@ config = configparser.ConfigParser()
config.read(CONF_FILE)
logging.basicConfig(format="%(asctime)s: %(message)s",
level=int(config['LOG_LEVEL']['log_level'])
)
REG_FILE = config['DEFAULT']['applications_db']
)

@ -34,7 +34,7 @@ def checkUserExists(username: str):
def checkUserInDB(username: str):
try:
L = lib.sqlitedb.SQLitedb(CFG.REG_FILE)
L = lib.sqlitedb.SQLitedb(CFG.config['DEFAULT']['applications_db'])
fetched = L.safequery("SELECT * FROM 'applications' WHERE username = ?", tuple([username]))
if fetched:
return True

Loading…
Cancel
Save