def first_time_setup():
    print("Thank you for using this mulitplication program.")
    print("You will now have to create an admin account for this system.")
    admin_username = input("Enter in your desired admin username: "******"Enter in your desired admin password: ")
    setup_session = db(admin_username, admin_password)
    db.create_table(
        setup_session
    )  # Creates the userLoginDetails table for the multiplication.db
    db.create_admin(
        setup_session
    )  # Adds the admin username and password to the userLoginDetails table
    db.close_connection(
        setup_session)  # Closes the cursor and connection to db


#first_time_setup() # First time setup complete (admin has been added)
#login_screen()
Beispiel #2
0
class Status:
    @logger.catch
    def __init__(self, module_name: AnyStr):
        self.all_codes = StatusCodes()
        self.code = self.all_codes.undefended
        self.module_name = module_name
        self.__db__ = Database(path='db/modules_stat.db')
        self.__stat__ = 'Undefended'
        self.__db__.create_table(
            table_name='statuses',
            rows={
                'module': 'TEXT PRIMARY KEY UNIQUE',
                'status': 'TEXT',
                'code': 'INTEGER DEFAULT 0',
            })
        self.undefended()

    @logger.catch
    def __bool__(self) -> bool:
        return self.code // 100 != 4

    @logger.catch
    def __save_status__(self):
        self.__db__.insert_or_replace(
            table_name='statuses',
            rows={
                'module': self.module_name,
                'status': self.__stat__,
                'code': self.code,
            })

    @logger.catch
    def undefended(self):
        self.__stat__ = 'Undefended'
        self.code = self.all_codes.undefended
        self.__save_status__()

    @logger.catch
    def finished(self):
        self.__stat__ = 'Finished'
        self.code = self.all_codes.finished
        self.__save_status__()

    @logger.catch
    def success(self):
        self.__stat__ = 'Success'
        self.code = self.all_codes.success
        self.__save_status__()

    @logger.catch
    def processing(self):
        self.__stat__ = 'Processing'
        self.code = self.all_codes.processing
        self.__save_status__()

    @logger.catch
    def looped(self):
        self.__stat__ = 'Looped'
        self.code = self.all_codes.looped
        self.__save_status__()

    @logger.catch
    def restarting(self):
        self.__stat__ = 'Restarting'
        self.code = self.all_codes.restarting
        self.__save_status__()

    @logger.catch
    def failed(self):
        self.__stat__ = 'Failed'
        self.code = self.all_codes.failed
        self.__save_status__()

    @logger.catch
    def fatal_error(self):
        self.__stat__ = 'Fatal error'
        self.code = self.all_codes.fatal_error
        self.__save_status__()

    @logger.catch
    def forced_stopped(self):
        self.__stat__ = 'Forced stopped'
        self.code = self.all_codes.forced_stopped
        self.__save_status__()