def __init__(this, data) -> None: ScrollableWindow.__init__(this, data) this.font_family = ConfigLoader.get("font-family") this.font_color = ConfigLoader.get("font-color") this.dao = AdDAO()
def __init__(this, data): Window.__init__(this, data) this.rowconfigure(index=0, weight=1) this.rowconfigure(index=1, weight=1) this.rowconfigure(index=2, weight=1) this.rowconfigure(index=3, weight=300) this.rowconfigure(index=4, weight=1) this.columnconfigure(index=0, weight=70) this.columnconfigure(index=1, weight=30) this.font_family = ConfigLoader.get("font-family") this.font_color = ConfigLoader.get("font-color") tkinter.Label(this, fg=this.font_color, bg=this['bg'], text="Hirdetés felvitele", font=(this.font_family, 25)).grid(row=0, column=0, columnspan=2) this.img = None this.filename = "" this.filename_label = tkinter.Label(this, fg=this.font_color, bg=this['bg'], text="Nincs feltöltött file", font=(this.font_family, 10)) this.filename_label.grid(row=2, column=1, sticky="N") ttk.Button(this, command=this.upload_poster, text="Fájl feltöltés").grid(row=1, column=1) ttk.Button(this, command=this.go_back, text="Vissza").grid(row=4, column=0, sticky="E") ttk.Button(this, command=this.insert_ad, text="Felvitel").grid(row=4, column=1, sticky="W") this.title = tkinter.Entry(this, width=70) this.text = tkinter.Text(this, width=100, height=50) this.title.grid(row=1, column=0, rowspan=2) this.text.grid(row=3, column=0, columnspan=2) this.dao = AdDAO() this.reset()
def test_parse_and_replace(): ''' parse_and_replaceで正しく値が変換されること ''' loader = ConfigLoader('') config = { 'DATA1': [ { 'DATA2': { 'DATA3': '{{ ENV:DATA4 }}', }, } ] } expected = { 'DATA1': [ { 'DATA2': { 'DATA3': 'EXPECTED', }, } ] } with mock.patch('os.environ.get', return_value='EXPECTED'): assert loader._parse_and_replace(config) == expected
def get_free_space(this, r_id): try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute( "SELECT COUNT(*) FROM UTKOZETRESZVETEL WHERE VERSENYID = :1", [r_id]) db_data: list[tuple] = cursor.fetchall() ossz = list() for s in db_data: ossz.append(s) cursor.execute("SELECT BESTOF FROM FORDULO WHERE VERSENYID = :1", [r_id]) db_data: list[tuple] = cursor.fetchall() bof = list() for s in db_data: bof.append(s) ConfigLoader.get_connection_pool().release(connection) free = bof[0][0] - ossz[0][0] return free except Exception as e: print(e) return list()
def __init__(this, data) -> None: Window.__init__(this, data) this.dao = UserDAO() # TEMPORARY WEIGHTS this.rowconfigure(index=0, weight=4) this.rowconfigure(index=1, weight=1) this.rowconfigure(index=2, weight=1) this.rowconfigure(index=3, weight=3) this.columnconfigure(index=0, weight=1) this.columnconfigure(index=1, weight=1) this.uname_entry: Union[None, Entry] = None this.pwd_entry: Union[None, Entry] = None font_family = ConfigLoader.get("font-family") font_color = ConfigLoader.get("font-color") header_color = "gray7" # TITLE Label(this, text="Infoglaló", fg=font_color, bg=header_color, font=(font_family, 26)).grid(row=0, column=0, columnspan=2, sticky="NESW") # FIELD NAMES Label(this, text="Felhasználónév: ", fg=font_color, bg=this["bg"], font=font_family).grid(row=1, column=0, sticky="SE") Label(this, text="Jelszó: ", fg=font_color, bg=this["bg"], font=font_family).grid(row=2, column=0, sticky="NE") # INPUT FIELDS this.uname_entry = Entry(this) this.pwd_entry = Entry(this, show="*") this.uname_entry.grid(row=1, column=1, sticky="SW") this.pwd_entry.grid(row=2, column=1, sticky="NW") # BUTTONS Button(this, text="Regisztráció", command=this.go_to_register).grid(row=3, column=0, sticky="EN") Button(this, text="Bejelentkezés", command=this.login2).grid(row=3, column=1, sticky="WN")
def executesql(this, sql, args: list) -> list: try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute(sql, args) ret = cursor.fetchall() ConfigLoader.get_connection_pool().release(connection) return ret except Exception as e: print(e) return list()
def make_room(this, r_id, r_name) -> bool: try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute("INSERT into kozosseg values (:1, :2)", [r_id, r_name]) connection.commit() ConfigLoader.get_connection_pool().release(connection) return True except Exception as e: print(e) return False
def insert_to_room(this, uname, room_id) -> bool: try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute("INSERT into kozossegtagja values (:1, :2)", [uname, room_id]) connection.commit() ConfigLoader.get_connection_pool().release(connection) return True except Exception as e: print(e) return False
def delete_comp(this, r_id) -> bool: try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute("DELETE FROM UTKOZETRESZVETEL WHERE VERSENYID = :1", [r_id]) connection.commit() ConfigLoader.get_connection_pool().release(connection) return True except Exception as e: print(e) return False
def get_all(self): try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute("SELECT FELHASZNALONEV FROM JATEKOS") result: list[tuple] = cursor.fetchall() ConfigLoader.get_connection_pool().release(connection) return result except Exception as e: print(e) return None
def add_answer(this, r_kerdes, r_name, r_adott, r_jel) -> bool: try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute("INSERT into ADOTTVALASZ values (-1, :1,:2,:3,:4)", [r_jel, r_kerdes, r_name, r_adott]) connection.commit() ConfigLoader.get_connection_pool().release(connection) return True except Exception as e: print(e) return False
def join_comp(this, r_id, r_name) -> bool: try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute("INSERT into UTKOZETRESZVETEL values (:1, :2)", [r_id, r_name]) connection.commit() ConfigLoader.get_connection_pool().release(connection) return True except Exception as e: print(e) return False
def reset(this) -> None: font_family = ConfigLoader.get("font-family") font_color = ConfigLoader.get("font-color") #MENU TITLE tkinter.Label(this, text="Válassz játékmódot!", fg=font_color, bg=this["bg"], font=(font_family, 26)).grid(row=0, column=0, sticky="NESW") #MENU BUTTONS Button(this, command=this.go_to_iq, text="IQ teszt").grid(row=1, column=0) Button(this, command=this.go_to_comp, text="Verseny").grid(row=2, column=0) Button(this, command=this.go_to_duel, text="Párbaj").grid(row=3, column=0) Button(this, command=this.go_to_test, text="Tematikus teszt").grid(row=4, column=0) Button(this, command=this.go_back, text="Vissza").grid(row=6, column=0)
def get_number(this, r_id): try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute("SELECT BESTOF FROM FORDULO WHERE VERSENYID=:1", [r_id]) db_data: list[tuple] = cursor.fetchall() ConfigLoader.get_connection_pool().release(connection) return db_data[0][0] except Exception as e: print(e) return 0
def run_comp(this, r_id): try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute("SELECT count(*) FROM UTKOZET WHERE VERSENYID=:1", [r_id]) db_data: list[tuple] = cursor.fetchall() db = db_data[0][0] ConfigLoader.get_connection_pool().release(connection) print(db_data) return not (db == 0) except Exception as e: print(e) return False
def join_play(this, r_id, r_name, r_date) -> bool: try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute( "INSERT into UTKOZET values (:1, TO_DATE(:2, 'YYYY-MM-DD-HH24:MI:SS'),:3)", [r_id, r_date, r_name]) connection.commit() ConfigLoader.get_connection_pool().release(connection) return True except Exception as e: print(e) return False
def update_msg(this, uname, time, new) -> bool: try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute( "UPDATE UZENET SET SZOVEG = :1 WHERE KULDO = :2 AND IDOPONT = :3", [new, uname, time]) connection.commit() ConfigLoader.get_connection_pool().release(connection) return True except Exception as e: print(e) return False
def send_message(this, u_name, room_id, content) -> bool: try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute( "INSERT INTO UZENET(KULDO, KOZOSSEG, IDOPONT, SZOVEG) VALUES (:1, :2, current_timestamp, :3)", [u_name, room_id, content]) connection.commit() ConfigLoader.get_connection_pool().release(connection) return True except Exception as e: print(e) return False
def get_room_id(this) -> int: try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute("SELECT max(ID)+1 FROM KOZOSSEG") db_data: list[tuple[int, str]] = cursor.fetchall() ConfigLoader.get_connection_pool().release(connection) result = list() for room_id in db_data: result.append((room_id)) return result[0][0] except Exception as e: print(e) return -1
def delete_forum_msg(this, uname, date) -> bool: try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute( "DELETE FROM UZENET WHERE KULDO = :1 AND IDOPONT = :2", [uname, date]) connection.commit() ConfigLoader.get_connection_pool().release(connection) return True except Exception as e: print(e) return False
def delete_reszvetel(this, r_id, r_name): try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute( "DELETE FROM UTKOZETRESZVETEL WHERE VERSENYID = :1 AND FELHASZNALONEV = :2", [r_id, r_name]) connection.commit() ConfigLoader.get_connection_pool().release(connection) return True except Exception as e: print(e) return False
def insert(self, uname: str, email: str, pwdhash: str, salt: str, birth_date: cx_Oracle.Date) -> bool: try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute( "INSERT INTO JATEKOS(FELHASZNALONEV, EMAIL, ADMIN, JELSZO, SALT, SZULDATUM) VALUES (:1, :2, :3, :4, :5, to_date(:6, 'yyyy-mm-dd'))", [uname, email, False, pwdhash, salt, birth_date]) connection.commit() ConfigLoader.get_connection_pool().release(connection) return True except Exception as e: print(e) return False
def __init__(this, data) -> None: Window.__init__(this, data) this.font_family = ConfigLoader.get("font-family") this.font_color = ConfigLoader.get("font-color") this.rowconfigure(index=0, weight=50) this.rowconfigure(index=1, weight=1) this.rowconfigure(index=2, weight=1) this.rowconfigure(index=3, weight=20) this.rowconfigure(index=4, weight=1) this.rowconfigure(index=5, weight=100) this.columnconfigure(index=0, weight=1) this.reset()
def get_non_member_room(this, u_name) -> list[tuple[int, str]]: try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute( "SELECT * FROM KOZOSSEG WHERE KOZOSSEG.ID != 0 and KOZOSSEG.ID not in (Select KOZOSSEG from KOZOSSEGTAGJA where FELHASZNALONEV = :1)", [u_name]) db_data: list[tuple[int, str]] = cursor.fetchall() ConfigLoader.get_connection_pool().release(connection) result = list() for room_id, room_name in db_data: result.append((room_id, room_name)) return result except Exception as e: print(e) return list()
def __init__(this, data) -> None: ScrollableWindow.__init__(this, data) this.main_frame.rowconfigure(index=0, weight=50) this.main_frame.rowconfigure(index=1, weight=1) this.main_frame.rowconfigure(index=2, weight=10) this.main_frame.rowconfigure(index=3, weight=1) this.main_frame.rowconfigure(index=4, weight=20) this.main_frame.rowconfigure(index=5, weight=1) this.main_frame.rowconfigure(index=6, weight=100) this.main_frame.columnconfigure(index=0, weight=1) this.main_frame.columnconfigure(index=1, weight=1) this.main_frame.columnconfigure(index=2, weight=1) this.main_frame.columnconfigure(index=3, weight=1) this.aggregate_data: list[str] = list() this.easy_data: list[str] = list() this.medium_data: list[str] = list() this.hard_data: list[str] = list() this.display_box: Union[tkinter.Listbox, None] = None this.aggregate_label: Union[tkinter.Button, None] = None this.easy_label: Union[tkinter.Button, None] = None this.medium_label: Union[tkinter.Button, None] = None this.hard_label: Union[tkinter.Button, None] = None this.highlight_color = ConfigLoader.get("accent-color") this.dao = TopListDAO() this.reset()
def get_new_id(this): try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute("SELECT max(ID)+1 FROM VERSENY") db_data: list[tuple[int, str]] = cursor.fetchall() if db_data[0][0] is None: return 1 ConfigLoader.get_connection_pool().release(connection) result = list() for v_id in db_data: result.append((v_id)) return result[0][0] except Exception as e: print(e) return -1
def get_unfinished_duel(this, challenger: str, challenged: str, pending: int) -> dict: try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute( "SELECT PARBAJ.ID, PARBAJKERDESE.SZOVEG, KERDES.BETUJEL FROM PARBAJ\ INNER JOIN PARBAJKERDESE ON PARBAJ.ID = PARBAJKERDESE.ID\ INNER JOIN PARBAJRAHIV ON PARBAJ.ID = PARBAJRAHIV.ID\ INNER JOIN PARBAJRAHIVOTT ON PARBAJ.ID = PARBAJRAHIVOTT.ID\ INNER JOIN KERDES ON PARBAJKERDESE.SZOVEG = KERDES.SZOVEG\ WHERE PARBAJRAHIV.JATEKOS = :1 AND PARBAJRAHIVOTT.JATEKOS = :2 AND PARBAJ.PENDING = :3 AND PARBAJ.NYERTES IS NULL", [challenger, challenged, pending]) data = cursor.fetchone() ret = {"id": data[0], "question": data[1], "correct_ans": data[2]} cursor.execute( "SELECT BETUJEL, SZOVEG FROM VALASZ WHERE KERDESSZOVEG = :1 ORDER BY BETUJEL ASC", [ret["question"]]) ret["answers"] = cursor.fetchall() return ret except Exception as e: print(e) return dict()
def get_comp_id(this, r_name): try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute("SELECT ID FROM VERSENY WHERE NEV = :1", [r_name]) db_data: list[tuple] = cursor.fetchall() ConfigLoader.get_connection_pool().release(connection) result = list() for id in db_data: result.append(id) return result except Exception as e: print(e) return list()
def is_playing(this, r_id, r_name): try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute( "SELECT count(*) FROM UTKOZET WHERE VERSENYID=:1 AND FELHASZNALONEV = :2", [r_id, r_name]) db_data: list[tuple] = cursor.fetchall() ossz = list() for s in db_data: ossz.append(s) ConfigLoader.get_connection_pool().release(connection) return not (ossz[0][0] == 0) except Exception as e: print(e) return False
def new_comp(this, r_id, r_name, r_date, r_best) -> bool: try: connection = ConfigLoader.get_connection_pool().acquire() cursor = connection.cursor() cursor.execute("INSERT into VERSENY values (:1, :2)", [r_id, r_name]) connection.commit() cursor.execute( "INSERT into FORDULO values (:1, to_date(:2, 'yyyy-mm-dd'), :3)", [r_id, r_date, int(r_best)]) connection.commit() ConfigLoader.get_connection_pool().release(connection) return True except Exception as e: print(e) return False