app/search_page.py
def add_fighter(self, fighter_name):
        """Run selenium background task in order to
        grab fighter's informations & add them to the database."""

        try:
            # db create table if not exists
            DatabaseManager().create_main_db_table()

            # find fighter in a web
            selenium_functions.run_driver(fighter_name=fighter_name, headless=True)

            # grab his stats
            stat_list, career_history = selenium_functions.grab_fighter_info()

            # add to db
            DatabaseManager().add_fighter(stat_list, career_history)

            # insert to GUI list
            data = DatabaseManager().return_fighter_names()
            added_fighter = list(data)[-1]
            name = added_fighter[0]
            alias = f" - {added_fighter[1]}" if added_fighter[1] else ''
            self.number += 1
            self.fighters_list.insert(
                self.number,
                f"{self.number}. {name}{alias}"
            )

            # inform user about successful completion
            end_time = round(time.perf_counter()-start_time)
            messagebox.showinfo(
                title="Success!",
                message=f"Fighter has been successfully found and added to "
                        f"database in {end_time} seconds!",
            )
        except Exception as e:
            selenium_functions.close_driver()
            messagebox.showerror(
                title="Failed!",
                message="Sir, we've got a temporary error!"
            )
            print(e)
Run selenium background task in order to
        grab fighter's informations & add them to the database.
Run selenium background task in order to
grab fighter's informations & add them to the database.
Run selenium background task in order to grab fighter ' s informations & add them to the database .
def add_fighter(self, fighter_name):
        try:
            DatabaseManager().create_main_db_table()
            selenium_functions.run_driver(fighter_name=fighter_name, headless=True)
            stat_list, career_history = selenium_functions.grab_fighter_info()
            DatabaseManager().add_fighter(stat_list, career_history)
            data = DatabaseManager().return_fighter_names()
            added_fighter = list(data)[-1]
            name = added_fighter[0]
            alias = f" - {added_fighter[1]}" if added_fighter[1] else ''
            self.number += 1
            self.fighters_list.insert(
                self.number,
                f"{self.number}. {name}{alias}"
            )
            end_time = round(time.perf_counter()-start_time)
            messagebox.showinfo(
                title="Success!",
                message=f"Fighter has been successfully found and added to "
                        f"database in {end_time} seconds!",
            )
        except Exception as e:
            selenium_functions.close_driver()
            messagebox.showerror(
                title="Failed!",
                message="Sir, we've got a temporary error!"
            )
            print(e)
def add_fighter ( self , fighter_name ) : try : DatabaseManager ( ) . create_main_db_table ( ) selenium_functions . run_driver ( fighter_name = fighter_name , headless = True ) stat_list , career_history = selenium_functions . grab_fighter_info ( ) DatabaseManager ( ) . add_fighter ( stat_list , career_history ) data = DatabaseManager ( ) . return_fighter_names ( ) added_fighter = list ( data ) [ - 1 ] name = added_fighter [ 0 ] alias = f" - {added_fighter[1]}" if added_fighter [ 1 ] else '' self . number += 1 self . fighters_list . insert ( self . number , f"{self.number}. {name}{alias}" ) end_time = round ( time . perf_counter ( ) - start_time ) messagebox . showinfo ( title = "Success!" , message = f"Fighter has been successfully found and added to " f"database in {end_time} seconds!" , ) except Exception as e : selenium_functions . close_driver ( ) messagebox . showerror ( title = "Failed!" , message = "Sir, we've got a temporary error!" ) print ( e )
Run selenium background task in order to
grab fighter's informations & add them to the database.
Run selenium background task in order to grab fighter ' s informations & add them to the database .
"""Run selenium background task in order to
        grab fighter's informations & add them to the database.""" # db create table if not exists # find fighter in a web # grab his stats # add to db # insert to GUI list # inform user about successful completion
self
fighter_name