it's freakin stupid to import IDs. Nothing depends on them. Ignore them.

pull/4/head
Darksider3 5 years ago
parent 96c403a3d9
commit 4760e35fda

@ -54,16 +54,12 @@ class Backup:
pass # empty tuple means everything pass # empty tuple means everything
try: try:
with open(fname, 'r', newline='') as f: with open(fname, 'r', newline='') as f:
import lib.sqlitedb as sql import lib.sqlitedb
import lib.System import lib.System
sysctl = lib.System.System() sysctl = lib.System.System()
sql = lib.sqlitedb.SQLitedb(CFG.REG_FILE) sql = lib.sqlitedb.SQLitedb(CFG.REG_FILE)
reader = csv.DictReader(f) # @TODO csv.Sniffer to compare? When yes, give force-accept option reader = csv.DictReader(f) # @TODO csv.Sniffer to compare? When yes, give force-accept option
for row in reader: for row in reader:
sql.safequery("INSERT INTO `applications` (id, username, name, timestamp, email, pubkey, status) "
"VALUES (?,?,?,?,?,?,?)",
tuple([row["id"], row["username"], row["name"], row["timestamp"],
row["email"], row["pubkey"], row["status"]])) # @TODO: without IDs
if row["status"] == "1": if row["status"] == "1":
sysctl.register(row["username"]) sysctl.register(row["username"])
sysctl.lock_user_pw(row["username"]) sysctl.lock_user_pw(row["username"])
@ -76,6 +72,10 @@ class Backup:
row['status'] + "not approved, therefore not registered.") row['status'] + "not approved, therefore not registered.")
else: else:
print(f"Uhm, ok. Type is {type(row['status'])}, and value is {row['status']}") print(f"Uhm, ok. Type is {type(row['status'])}, and value is {row['status']}")
sql.safequery("INSERT INTO `applications` (username, name, timestamp, email, pubkey, status) "
"VALUES (?,?,?,?,?,?)",
tuple([row["username"], row["name"], row["timestamp"],
row["email"], row["pubkey"], row["status"]])) # @TODO: without IDs
pass # @TODO: Import with sqlitedb and system. Will be fun Kappa pass # @TODO: Import with sqlitedb and system. Will be fun Kappa
except OSError as E: except OSError as E:
print(f"UUFFF, something went WRONG with the file {fname}: {E}") print(f"UUFFF, something went WRONG with the file {fname}: {E}")

@ -1,11 +1,13 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import re, configparser, logging, sqlite3, argparse import argparse
from os import getcwd import configparser
import logging
import re
import sqlite3
from os import environ from os import environ
from os import getcwd
from os import path as ospath from os import path as ospath
import re, configparser, logging, sqlite3
try: try:
cwd = environ.get('TILDE_CONF') cwd = environ.get('TILDE_CONF')
@ -19,12 +21,6 @@ try:
argparser.add_argument('-c', '--config', default=cwd, type=str, help='Config file', required=False) argparser.add_argument('-c', '--config', default=cwd, type=str, help='Config file', required=False)
args = argparser.parse_args() args = argparser.parse_args()
CONF_FILE = args.config CONF_FILE = args.config
except:
# intended broad, @TODO check them all for errors instead of everything in one
logging.exception("Argumentparser-Exception: ")
exit(0)
try:
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read(CONF_FILE) config.read(CONF_FILE)
logging.basicConfig(format="%(asctime)s: %(message)s", filename=config['DEFAULT']['log_file'], logging.basicConfig(format="%(asctime)s: %(message)s", filename=config['DEFAULT']['log_file'],
@ -91,8 +87,8 @@ def check_username(value):
from pwd import getpwnam from pwd import getpwnam
getpwnam(value) getpwnam(value)
VALID_USER = False VALID_USER = False
# intended broad # everything from pwd throws an KeyError when the given user cannot be found
except Exception: except KeyError:
VALID_USER = True VALID_USER = True
return True return True
return False return False
@ -127,7 +123,8 @@ def validate_pubkey(value):
def main(): def main():
print(" ▗▀▖ \n▗▖▖ ▐ ▌ ▌▛▀▖\n▘▝▗▖▜▀ ▌ ▌▌ ▌\n ▝▘▐ ▝▀▘▘ ▘") print(" ▗▀▖ \n▗▖▖ ▐ ▌ ▌▛▀▖\n▘▝▗▖▜▀ ▌ ▌▌ ▌\n ▝▘▐ ▝▀▘▘ ▘")
username = input("Welcome to the ~.fun user application form!\n\nWhat is your desired username? [a-z0-9] allowed:\n") username = input("Welcome to the ~.fun user application form!\n\n"
"What is your desired username? [a-z0-9] allowed:\n")
while (not re.match("[a-z]+[a-z0-9]", username)) or (not check_username(username)): while (not re.match("[a-z]+[a-z0-9]", username)) or (not check_username(username)):
username = input("Invalid Username, maybe it exists already?\nValid characters are only a-z and 0-9." username = input("Invalid Username, maybe it exists already?\nValid characters are only a-z and 0-9."
"\nMake sure your username starts with a character and not a number" "\nMake sure your username starts with a character and not a number"

Loading…
Cancel
Save