From a17d0ed30f6a3b8ccb9d0635873f5c77de8a1ff0 Mon Sep 17 00:00:00 2001 From: Darksider3 Date: Tue, 22 Oct 2019 15:56:05 +0200 Subject: [PATCH] ListUsers: UAP and APP => Unapproved and Approved replaced --- private/Backup.py | 3 ++- private/ListUsers.py | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/private/Backup.py b/private/Backup.py index bd324e2..21d131c 100755 --- a/private/Backup.py +++ b/private/Backup.py @@ -53,7 +53,8 @@ class Backup: if __name__ == "__main__": try: - L = ListUsers.ListUsers(config['DEFAULT']['applications_db'], uap=args.unapproved, app=args.approved) + L = ListUsers.ListUsers(config['DEFAULT']['applications_db'], + unapproved=args.unapproved, approved=args.approved) fetch = L.getFetch() B = Backup(args.file) B.BackupToFile(fetch) diff --git a/private/ListUsers.py b/private/ListUsers.py index 2b96b7d..d59afca 100755 --- a/private/ListUsers.py +++ b/private/ListUsers.py @@ -4,29 +4,22 @@ from lib.sqlitedb import SQLitedb import configparser import lib.uis.default as default_cmd # Follows -u, -a, -f flags -default_cmd.argparser.description += " - Lists Users from the Tilde database." -default_cmd.argparser.add_argument('--list', default=False, action="store_true", - help='Output a newline seperated list of users', required=False) -args = default_cmd.argparser.parse_args() -config = configparser.ConfigParser() -config.read(args.config) - class ListUsers: db = None usersFetch = None - def __init__(self, db: str, uap: bool = False, app: bool = True): + def __init__(self, db: str, unapproved: bool = False, approved: bool = True): self.db = SQLitedb(db) - if uap: # only unapproved users + if unapproved: # only unapproved users query = "SELECT * FROM `applications` WHERE `status` = '0'" - elif app: # Approved users + elif approved: # Approved users query = "SELECT * FROM `applications` WHERE `status` = '1'" else: # All users query = "SELECT * FROM `applications`" self.usersFetch = self.db.query(query) - def outputaslist(self) -> str: + def output_as_list(self) -> str: list_str: str = "" query = "SELECT `username` FROM `applications` WHERE `status` = '1' ORDER BY timestamp ASC" self.usersFetch = self.db.query(query) @@ -69,11 +62,18 @@ print(t.draw()) )) """ if __name__ == "__main__": + default_cmd.argparser.description += " - Lists Users from the Tilde database." + default_cmd.argparser.add_argument('--list', default=False, action="store_true", + help='Output a newline seperated list of users', required=False) + args = default_cmd.argparser.parse_args() + config = configparser.ConfigParser() + config.read(args.config) + try: ret = "" - L = ListUsers(config['DEFAULT']['applications_db'], uap=args.unapproved, app=args.approved) + L = ListUsers(config['DEFAULT']['applications_db'], unapproved=args.unapproved, approved=args.approved) if args.list: - ret = L.outputaslist() + ret = L.output_as_list() else: fetch = L.getFetch() ret += "ID %-1s| Username %-5s| Mail %-20s| Name %-17s| Registered %-8s | State |\n" % (