Beispiel #1
0
    def validation_button_command(self):

        encoded_username = sha256(self.gui.administrator_log_in.username_entry.get().encode("utf-8")).hexdigest()
        encoded_password = sha256(self.gui.administrator_log_in.password_entry.get().encode("utf-8")).hexdigest()

        if not self.gui.administrator_log_in.admin_registration:
            if encoded_username in self.gui.admins.keys() and encoded_password == self.gui.admins[encoded_username]:

                if self.gui.administrator_log_in.itemcget(self.gui.administrator_log_in.validation_error_message_id,
                                                          "state") \
                        == "normal":
                    self.gui.administrator_log_in.itemconfigure(
                        self.gui.administrator_log_in.validation_error_message_id,
                        state="hidden")

                self.gui.administrator_log_in.hide()
                self.gui.parameters_menu.display()

            else:
                self.gui.administrator_log_in.itemconfigure(self.gui.administrator_log_in.validation_error_message_id,
                                                            state="normal")

        elif self.gui.administrator_log_in.admin_registration:
            self.gui.admins[f"{encoded_username}"] = encoded_password
            Log().write_log_info(message="Un compte administrateur pour l'utilisateur "
                                         f"{self.gui.administrator_log_in.username_entry.get()} a été créé.")
            self.gui.administrator_log_in.toggle_admin_registration()
            self.gui.administrator_log_in.hide()
            self.gui.parameters_menu.display()
    def load_assets(self):

        try:
            self.background_image = ResizableImage(path_to_image="assets/background.png")
            self.global_background_image = self.background_image.resize_to_tk(width=self.width,
                                                                              height=self.height)
            self.cm_logo_image = ResizableImage(path_to_image="assets/cm_logo.png")
            self.global_cm_logo_image = self.cm_logo_image.resize_to_tk(width=0.2 * self.width)
            self.registration_button_image = ResizableImage(path_to_image="assets/registration_button.png")
            self.registration_button_on_click_image = ResizableImage(
                path_to_image="assets/registration_button_on_click.png")
            self.schedule_button_image = ResizableImage(path_to_image="assets/schedule_button.png")
            self.schedule_button_on_click_image = ResizableImage(path_to_image="assets/schedule_button_on_click.png")
            self.parameters_button = ResizableImage(path_to_image="assets/parameters_button.png")
            self.parameters_button_on_click = ResizableImage(path_to_image="assets/parameters_button_on_click.png")
            self.return_button_image = ResizableImage(path_to_image="assets/return_button.png")
            self.return_button_on_click_image = ResizableImage(path_to_image="assets/return_button_on_click.png")

            for language in self.text_resources.keys():
                self.language_assets[language] = [
                    ResizableImage(path_to_image=f"assets/{language}_button.png"),
                    ResizableImage(path_to_image=f"assets/{language}_button_on_click.png")]

        except:
            Log().write_log_exception(level="error", message="An error occurred while loading the assets.",
                                      show=True, log=True)
Beispiel #3
0
def run():
    systemLog = Log()
    threads = []
    sessions = {}
    proxy = Proxy().random_proxy()
    while 1:
        payments = Payment().get_payments()
        for p in payments:
            payment = Payment()
            payment = payment.set_payment(p)
            name = payment.get_name()
            type = payment.get_type()
            if payment.get_status() == 0:
                continue
            connector_module = 'connector.http.' + name.lower()
            if type == 'enterprise':
                connector_module += '_enterprise'
                name += 'Enterprise'
            module = importlib.import_module(connector_module)
            class_ = getattr(module, name)
            sessions[name] = Session(proxy)
            connector = class_(payment, sessions[name], proxy)
            if sessions[name].is_changing_proxy() == 1:
                systemLog.log('Need to change ' + name + ' proxy!', 'debug')
                proxy = Proxy().random_proxy()
            thread_name = "Thread " + str(
                payment.get_id()) + " " + name + " " + type
            thread = ThreadConnector(thread_name.upper(), connector, 5)
            thread.start()
            threads.append(thread)
        for t in threads:
            t.join(60)
Beispiel #4
0
 def map_dict_to_entity(log_dict):
     entity = Log(
         log_dict['username'],
         log_dict['source_host'],
         log_dict['target_host'],
         log_dict['api_url'],
         datetime.strptime(log_dict['created_datetime'], '%Y-%m-%d %H:%M:%S')
     )
     return entity
    def register_student(self, student_to_register, encoding):

        try:
            student_to_register.set_face_encoding(encoding=encoding)
            student_to_register.dump_info()

        except:
            Log().write_log_exception(level="error",
                                      message=f"Un problème est survenu lors de "
                                              f"l'enregistrement de {str(student_to_register)}",
                                      show=True,
                                      log=True)

        else:
            Log().write_log_info(f"L'étudiant.e {str(student_to_register)} a "
                                f"bien été enregistré.e!", show=True)

            self.gui.root.after(1000, self.done.set(value=True))
    def load_database(self):

        try:

            with open("students.txt", 'r') as file:
                self.database = json.load(file)

        except:
            Log().write_log_exception(level="error", message="An error occurred while loading the students database.",
                                      show=True, log=True)
    def load_admins(self):

        try:

            with open("administrators.txt", 'r') as file:
                self.admins = json.load(file)

        except:
            Log().write_log_exception(level="error",
                                      message="An error occurred while loading the administrators database.",
                                      show=True, log=True)
Beispiel #8
0
    def adjust_scrollable_region(self, for_keyboard=False):

        try:
            region = sum([int(elem[0].cget("height")) // 4.3 for elem in self.canvas_dict.values()])

            if for_keyboard:
                region += self.gui.touch_keyboard.height

            self.canvas.configure(scrollregion=(0, 0, 0, region))

        except:
            Log().write_log_exception()
    def load_assets(self):

        try:
            self.background_image = ResizableImage(
                path_to_image="assets/background.png")
            self.global_background_image = self.background_image.resize_to_tk(
                width=self.width, height=self.height)
            self.cm_logo_image = ResizableImage(
                path_to_image="assets/cm_logo.png")
            self.global_cm_logo_image = self.cm_logo_image.resize_to_tk(
                width=0.2 * self.width)
            self.registration_button_image = ResizableImage(
                path_to_image="assets/registration_button.png")
            self.registration_button_on_click_image = ResizableImage(
                path_to_image="assets/registration_button_on_click.png")
            self.schedule_button_image = ResizableImage(
                path_to_image="assets/schedule_button.png")
            self.schedule_button_on_click_image = ResizableImage(
                path_to_image="assets/schedule_button_on_click.png")
            self.parameters_button = ResizableImage(
                path_to_image="assets/parameters_button.png")
            self.parameters_button_on_click = ResizableImage(
                path_to_image="assets/parameters_button_on_click.png")
            self.return_button_image = ResizableImage(
                path_to_image="assets/return_button.png")
            self.return_button_on_click_image = ResizableImage(
                path_to_image="assets/return_button_on_click.png")
            self.modify_text_button_image = ResizableImage(
                path_to_image="assets/modify_text.png")
            self.validate_modification_button_image = ResizableImage(
                path_to_image="assets/validate_modification_button.png")
            self.cancel_modification_button_image = ResizableImage(
                path_to_image="assets/cancel_modification_button.png")

            for language in self.text_resources.keys():
                self.language_assets[language] = [
                    ResizableImage(
                        path_to_image=f"assets/{language}_button.png"),
                    ResizableImage(
                        path_to_image=f"assets/{language}_button_on_click.png")
                ]

        except:
            Log().write_log_exception(
                level="error",
                message=
                "Une erreur est survenue lors du chargement des éléments "
                "visuels.",
                show=True,
                log=True)
Beispiel #10
0
 def __init__(self, payment, session=None, proxy={}):
     self.session = session
     self.proxy = proxy
     self.payment = payment
     self.config = Config()
     self.log = Log()
     techcombank = self.get_techcombank_config()
     self.email_transport = EmailTransport()
     self.login_url = techcombank['login_url']
     self.username = payment.get_username()
     self.password = payment.get_password()
     self.debug_mode = techcombank['debug_mode']
     self.total_transactions = 0
     self.history = History()
     self.code = GenerateCode()
Beispiel #11
0
 def save(data):
     if data is not None:
         entity = Log(
             un=data['user_name'],
             th=data['target_host'],
             sh=data['source_host'],
             cdt=datetime.strptime(data['created_datetime'],
                                   '%Y-%m-%d %H:%M:%S'),
             au=data['api_url'],
         )
         db.session.add(entity)
         try:
             db.session.commit()
         except SQLAlchemyError:
             return None
         return entity
    def close_app(self):

        try:

            with open("students.txt", 'w') as file:
                json.dump(self.database, file, sort_keys=True, indent=4)

            with open("administrators.txt", 'w') as file:
                json.dump(self.admins, file, sort_keys=True, indent=4)

        except:
            Log().write_log_exception(level="error", message="The application didn't close properly.",
                                      show=False, log=True)

        finally:
            self.root.quit()
Beispiel #13
0
 def __init__(self, payment, session=None, proxy={}):
     self.payment = payment
     self.session = session
     self.proxy = proxy
     self.config = Config()
     self.log = Log()
     self.code = GenerateCode()
     self.email_transport = EmailTransport()
     section_config = self.get_section_config()
     self.dashboard_url = section_config['dashboard_url']
     self.balance_url = section_config['balance_url']
     self.account_info_url = section_config['account_info_url']
     self.account_statement_url = section_config['account_statement_url']
     self.username = payment.get_username()
     self.password = payment.get_password()
     self.debug_mode = section_config['debug_mode']
     self.total_transactions = 0
     self.file = File()
    def pushPlipToTrelloBoard(self):
        log = Log()
        #recover date from last Sync and displays it before accually syncs
        lastSyncDate = self.log.recoverLastSync('TRELLO_SYNC')
        #for p in Petition.where(Petition.submitDate >= lastSyncDate).get():
        count = 0
        print("Last sync: " + str(lastSyncDate))

        for petition in Petition.select().where(Petition.submitDate >= lastSyncDate):
            print(petition.plip_name)
            count += self.trello.createCard(petition)
        print("Tototal of [" + str(count) +"] roposes pushed to Trello board")
            
        #if plip finishes now will create a log for it
        now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        log.motive = "TRELLO_SYNC"
        log.quantity = count
        log.sync_date = now
        self.log.createLogSyncPL(log.sync_date, log.quantity, log.motive)
 def __init__(self, payment, session=None, proxy={}):
     self.session = session
     self.proxy = proxy
     self.config = Config()
     self.log = Log()
     self.username = payment.get_username()
     self.password = payment.get_password()
     sacombank = self.get_config()
     self.email_transport = EmailTransport()
     self.corp_url = sacombank['corp_url']
     self.captcha = CaptchaResolver()
     self.debug_mode = sacombank['debug_mode']
     self.total_transactions = 0
     self.history = History()
     self.code = GenerateCode()
     self.max_attempt_login = 20
     self.login_failed = 0
     self.session = session
     self.proxy = proxy
     self.payment = payment
Beispiel #16
0
 def __init__(self, name=None, session=None, proxy={}):
     self.session = session
     self.proxy = proxy
     self.config = Config()
     self.log = Log()
     self.captcha = CaptchaResolver()
     section_config = self.get_section_config(name)
     self.email_transport = EmailTransport()
     self.home_url = section_config['home_url']
     self.login_url = section_config['login_url']
     self.username = section_config['username']
     self.password = section_config['password']
     self.debug_mode = section_config['debug_mode']
     self.total_transactions = 0
     self.max_attempt_login = 10
     self.max_validate_captcha = 10
     self.login_failed = 0
     self.captcha_failed = 0
     self.history = History()
     self.code = GenerateCode()
Beispiel #17
0
 def __init__(self, payment, session=None, proxy={}):
     self.payment = payment
     self.session = session
     self.proxy = {}
     self.captcha = CaptchaResolver()
     self.config = Config()
     self.log = Log()
     self.history = History()
     self.code = GenerateCode()
     self.email_transport = EmailTransport()
     section_config = self.get_msb_config()
     self.username = payment.get_username()
     self.password = payment.get_password()
     self.home_url = section_config['home_url']
     self.login_url = section_config['login_url']
     self.account_list_url = section_config['account_list_url']
     self.account_info_url = section_config['account_info_url']
     self.debug_mode = section_config['debug_mode']
     self.total_transactions = 0
     self.max_attempt_login = 10
     self.max_validate_captcha = 10
     self.login_failed = 0
     self.captcha_failed = 0
from model.log import Log
from view.gui import GUI

try:
    gui = GUI()

    gui.start_menu.display()

    gui.root.mainloop()

except:
    Log().write_log_exception(level="error",
                              message="Un problème est survenu lors de l'exécution de l'application.",
                              show=True,
                              log=False)

Beispiel #19
0
 def __init__(self, name, connector, delay):
     threading.Thread.__init__(self)
     self.name = name
     self.connector = connector
     self.log = Log()
     self.delay = delay
Beispiel #20
0
def run():
    log = Log()
    log.notify()
 def __init__(self):   
     self.trello = Trello()
     self.log = Log()    
     self.petitionsList = []
     self.petition = Petition()