diff --git a/__pycache__/cls_mth_fc.cpython-312.pyc b/__pycache__/cls_mth_fc.cpython-312.pyc index 3009fde..913ab8c 100644 Binary files a/__pycache__/cls_mth_fc.cpython-312.pyc and b/__pycache__/cls_mth_fc.cpython-312.pyc differ diff --git a/cls_mth_fc.py b/cls_mth_fc.py index f83f2cc..f78278c 100755 --- a/cls_mth_fc.py +++ b/cls_mth_fc.py @@ -111,7 +111,7 @@ class Create: print(f"Error with the following code... {process.returncode}") else: print(_("Ready for import")) - + @staticmethod def encrypt(): """ @@ -138,7 +138,7 @@ def uos(): This method displays the user name of the logged-in user, even if you are rooted in a shell """ - logname = str(Path.home())[6:] + logname = f"{Path.home()}"[6:] file = Path.home() / "/tmp/.loguser" with open(file, "w", encoding="utf-8") as f: f.write(logname) @@ -181,10 +181,10 @@ class GiteaUpdate: this is for download new Version of wirepy """ try: - to_down = "wget -qP " + str(Path.home()) + " " + urld + to_down = f"wget -qP {Path.home()} {" "} {urld}" result = subprocess.call(to_down, shell=True) if result == 0: - shutil.chown(str(Path.home()) + f"/{res}.zip", 1000, 1000) + shutil.chown(f"{Path.home()}/{res}.zip", 1000, 1000) # img_w, img_i, w_title, w_txt hand over iw = r"/usr/share/icons/lx-icons/64/info.png" @@ -342,17 +342,17 @@ class Tunnel: in the user's home directory with correct right """ now_time = datetime.now() - now_datetime = now_time.strftime("wg-exp-" + "%m-%d-%Y" + "-" + "%H:%M") + now_datetime = now_time.strftime(f"wg-exp-%m-%d-%Y-%H:%M") tl = Tunnel.list() try: if len(tl) != 0: - wg_tar = str(Path.home()) + "/" + now_datetime + wg_tar = f"{Path.home()}/{now_datetime}" shutil.copytree("/tmp/tlecdcwg/", "/tmp/wire_py", dirs_exist_ok=True) source = Path("/tmp/wire_py") shutil.make_archive(wg_tar, "zip", source) shutil.rmtree(source) - with zipfile.ZipFile((wg_tar + ".zip"), "r") as zf: + with zipfile.ZipFile(f"{wg_tar}.zip", "r") as zf: if len(zf.namelist()) != 0: # img_w, img_i, w_title, w_txt hand over @@ -461,14 +461,21 @@ class Tooltip: return x, y, _, _ = self.widget.bbox("insert") - x += self.widget.winfo_rootx() + 40 + x += self.widget.winfo_rootx() + 65 y += self.widget.winfo_rooty() + 40 self.tooltip_window = tw = tk.Toplevel(self.widget) tw.wm_overrideredirect(True) tw.wm_geometry(f"+{x}+{y}") label = tk.Label( - tw, text=self.text, relief="solid", borderwidth=1, padx=5, pady=5 + tw, + text=self.text, + background="lightgreen", + foreground="black", + relief="solid", + borderwidth=1, + padx=5, + pady=5, ) label.grid() diff --git a/ssl_decrypt.py b/ssl_decrypt.py index 7cb4630..cb3ef98 100755 --- a/ssl_decrypt.py +++ b/ssl_decrypt.py @@ -33,16 +33,16 @@ if not keyfile.is_file(): ) shutil.chown(keyfile, 1000, 1000) -dirname2 = "/home/" + logname + "/.config/wire_py/" +dirname2 = f"/home/{logname}/.config/wire_py/" detl = os.listdir(dirname2) os.chdir(dirname2) detl.remove("keys") detl.remove("settings") -if os.path.exists(dirname2 + "pbwgk.pem"): +if os.path.exists(f"{dirname2}pbwgk.pem"): detl.remove("pbwgk.pem") for detunnels in detl: - tlname2 = detunnels[:-4] + ".conf" - extpath = str(dirname) + "/" + tlname2 + tlname2 = f"{detunnels[:-4]}.conf" + extpath = f"{dirname}/{tlname2}" check_call( [ "openssl", diff --git a/ssl_encrypt.py b/ssl_encrypt.py index 4f05032..4069f79 100755 --- a/ssl_encrypt.py +++ b/ssl_encrypt.py @@ -33,14 +33,14 @@ if not keyfile.is_file(): shutil.chown(keyfile, 1000, 1000) if dirname.exists(): - tl = os.listdir(str(dirname)) - CPTH = str(keyfile) + tl = os.listdir(f"{dirname}") + CPTH = f"{keyfile}" CRYPTFILES = CPTH[:-9] if keyfile.exists() and len(tl) != 0: for tunnels in tl: - sourcetl = str(dirname) + "/" + tunnels - tlname = CRYPTFILES + tunnels[:-5] + ".dat" + sourcetl = f"{dirname}/{tunnels}" + tlname = f"{CRYPTFILES}{tunnels[:-5]}.dat" check_call( [ "openssl", @@ -59,14 +59,14 @@ if not keyfile.is_file(): else: if dirname.exists(): - tl = os.listdir(str(dirname)) - CPTH = str(keyfile) + tl = os.listdir(f"{dirname}") + CPTH = f"{keyfile}" CRYPTFILES = CPTH[:-9] if keyfile.exists() and len(tl) != 0: for tunnels in tl: - sourcetl = str(dirname) + "/" + tunnels - tlname = CRYPTFILES + tunnels[:-5] + ".dat" + sourcetl = f"{dirname}/{tunnels}" + tlname = f"{CRYPTFILES}{tunnels[:-5]}.dat" check_call( [ "openssl", diff --git a/wirepy.py b/wirepy.py index 0bc2fb8..d1a7074 100755 --- a/wirepy.py +++ b/wirepy.py @@ -67,7 +67,7 @@ class Wirepy(tk.Tk): self.rowconfigure(0, weight=1) self.style = ttk.Style(self) - self.tk.call("source", str(tcl_path) + "/water.tcl") + self.tk.call("source", f"{tcl_path}/water.tcl") with open(wg_set, "r", encoding="utf-8") as read_file: lines = read_file.readlines() if "light\n" in lines: @@ -261,7 +261,7 @@ class FrameWidgets(ttk.Frame): else: set_update.set(value=0) - text = f"Update {res} " + _("available!") + text = f"Update {res} {_("available!")}" # Update BTN Menu self.update_btn = ttk.Menubutton(self.menu_frame, text=text) @@ -303,9 +303,8 @@ class FrameWidgets(ttk.Frame): # Bottom Frame 4 self.lb_frame3 = ttk.Frame(self) self.lb_frame3.configure(relief="flat") - self.lb_frame3.grid( - column=0, row=5, columnspan=4, sticky="snew", padx=2, pady=2 - ) + self.lb_frame3.grid(column=0, row=5, columnspan=4, sticky="snew", + padx=2, pady=2) # Bottom Frame 5 self.lb_frame4 = ttk.Frame(self) @@ -364,7 +363,7 @@ class FrameWidgets(ttk.Frame): # Button Vpn if self.a != "": self.stop() - wg_read = "/tmp/tlecdcwg/" + str(self.a + ".conf") + wg_read = f"/tmp/tlecdcwg/{self.a}.conf" with open(wg_read, "r", encoding="utf-8") as file: data = Tunnel.con_to_dict(file) @@ -382,12 +381,8 @@ class FrameWidgets(ttk.Frame): self.show_data() # Button Import - self.btn_i = ttk.Button( - self.lb_frame_btn_lbox, - image=self.imp_pic, - command=self.import_sl, - padding=0, - ) + self.btn_i = ttk.Button(self.lb_frame_btn_lbox, image=self.imp_pic, + command=self.import_sl, padding=0) self.btn_i.grid(column=0, row=1, padx=15, pady=8) Tooltip(self.btn_i, _("Click to import a Wireguard Tunnel"), tips) @@ -399,8 +394,7 @@ class FrameWidgets(ttk.Frame): try: self.select_tunnel = self.l_box.curselection() select_tl = self.l_box.get(self.select_tunnel[0]) - with open( - "/tmp/tlecdcwg/" + select_tl + ".conf", "r+", encoding="utf-8" + with open(f"/tmp/tlecdcwg/{select_tl}.conf", "r+", encoding="utf-8" ) as file2: key = Tunnel.con_to_dict(file2) pre_key = key[3] @@ -417,24 +411,16 @@ class FrameWidgets(ttk.Frame): set_file7.writelines(lines6) self.selected_option.set(0) self.autoconnect_var.set(_("no Autoconnect")) - is_encrypt = Path.home() / ".config/wire_py" / str(select_tl + ".dat") + is_encrypt = Path.home() / f".config/wire_py/{select_tl}.dat" if is_encrypt.is_file(): - Path.unlink( - str(Path.home()) + "/.config/wire_py/" + str(select_tl + ".dat") - ) - Path.unlink(Path("/tmp/tlecdcwg") / str(select_tl + ".conf")) - with open( - str(Path.home()) + "/.config/wire_py/keys", "r", encoding="utf-8" - ) as readfile: - with open( - str(Path.home()) + "/.config/wire_py/keys2", - "w", - encoding="utf-8", - ) as writefile: + Path.unlink(f"{Path.home()}/.config/wire_py/{select_tl}.dat") + Path.unlink(f"/tmp/tlecdcwg/{select_tl}.conf") + with open(f"{Path.home()}/.config/wire_py/keys", "r", encoding="utf-8") as readfile: + with open(f"{Path.home()}/.config/wire_py/keys2", "w", encoding="utf-8") as writefile: for line in readfile: if pre_key not in line.strip("\n"): writefile.write(line) - file_one = Path(str(Path.home()) + "/.config/wire_py/keys2") + file_one = Path(f"{Path.home()}/.config/wire_py/keys2") file_two = file_one.with_name("keys") file_one.replace(file_two) self.wg_autostart.configure(state="disabled") @@ -443,21 +429,13 @@ class FrameWidgets(ttk.Frame): if self.l_box.size() == 0: self.wg_autostart.configure(state="disabled") self.lb_rename.configure(state="disabled") - Tooltip( - self.wg_autostart, - _( - "You must have at least one\ntunnel in the list,to use the autostart" - ), - tips, - ) + Tooltip(self.wg_autostart, _("You must have at least one\ntunnel", + "in the list,to use the autostart"), tips) Tooltip(self.btn_exp, _("No Tunnels in List for Export"), tips) Tooltip(self.btn_stst, _("No tunnels to start in the list"), tips) - Tooltip( - self.lb_rename, - _("To rename a tunnel, at least one must be in the list"), - tips, - ) + Tooltip(self.lb_rename, _("To rename a tunnel, at least one must", + "be in the list"), tips,) self.lb_rename.insert(0, _("Max. 12 characters!")) if self.a != "" and self.a == select_tl: @@ -503,9 +481,7 @@ class FrameWidgets(ttk.Frame): if self.l_box.size() == 0: Tooltip(self.btn_tr, _("No tunnels to delete in the list"), tips) else: - Tooltip( - self.btn_tr, - _("Click to delete a Wireguard Tunnel\nSelect from the list!"), + Tooltip(self.btn_tr, _("Click to delete a Wireguard Tunnel\nSelect from the list!"), tips, ) @@ -520,7 +496,7 @@ class FrameWidgets(ttk.Frame): else: Tooltip( self.btn_exp, - _(" Click to export all\nWireguard Tunnel to Zipfile"), + _("Click to export all\nWireguard Tunnel to Zipfile"), tips, ) @@ -593,12 +569,11 @@ class FrameWidgets(ttk.Frame): self.lb_rename.get(), ] ) - source = Path("/tmp/tlecdcwg") / str(select_tl + ".conf") - destination = source.with_name(str(self.lb_rename.get() + ".conf")) + source = Path(f"/tmp/tlecdcwg/{select_tl}.conf") + destination = source.with_name(f"{self.lb_rename.get()}.conf") source.replace(destination) - Path.unlink( - str(Path.home()) + "/.config/wire_py/" + str(select_tl + ".dat") - ) + Path.unlink(f"{Path.home()}/.config/wire_py/{select_tl}.dat") + self.l_box.delete(self.select_tunnel[0]) self.l_box.insert("end", self.lb_rename.get()) self.l_box.update() @@ -703,7 +678,7 @@ class FrameWidgets(ttk.Frame): try: filepath = filedialog.askopenfilename( - initialdir=str(Path.home()), + initialdir=f"{Path.home()}", title=_("Select Wireguard config File"), filetypes=[(_("WG config files"), "*.conf")], ) @@ -723,13 +698,9 @@ class FrameWidgets(ttk.Frame): key = Tunnel.con_to_dict(file) pre_key = key[3] if len(pre_key) != 0: - with open( - str(Path.home()) + "/.config/wire_py/keys", - "r", - encoding="utf-8", - ) as readfile: + with open(f"{Path.home()}/.config/wire_py/keys", "r", encoding="utf-8") as readfile: p_key = readfile.readlines() - if pre_key in p_key or pre_key + "\n" in p_key: + if pre_key in p_key or f"{pre_key}\n" in p_key: # img_w, img_i, w_title, w_txt hand over iw = r"/usr/share/icons/lx-icons/64/error.png" @@ -742,21 +713,17 @@ class FrameWidgets(ttk.Frame): else: - with open( - str(Path.home()) + "/.config/wire_py/keys", - "a", - encoding="utf-8", - ) as keyfile: - keyfile.write(pre_key + "\r") + with open(f"{Path.home()}/.config/wire_py/keys", "a", encoding="utf-8") as keyfile: + keyfile.write(f"{pre_key}\r") if len(path_split1) > 17: p1 = shutil.copy(filepath, "/tmp/tlecdcwg/") path_split = path_split1[ len(path_split1) - 17 : ] os.rename( - p1, "/tmp/tlecdcwg/" + str(path_split) + p1, f"/tmp/tlecdcwg/{path_split}" ) - new_conf = "/tmp/tlecdcwg/" + path_split + new_conf = f"/tmp/tlecdcwg/{path_split}" if self.a != "": check_call( [ @@ -859,7 +826,7 @@ class FrameWidgets(ttk.Frame): self.str_var.set(self.a) self.color_label() self.stop() - wg_read = "/tmp/tlecdcwg/" + str(self.a + ".conf") + wg_read = f"/tmp/tlecdcwg/{self.a}.conf" with open( wg_read, "r", encoding="utf-8" ) as file_for_key: @@ -976,11 +943,11 @@ class FrameWidgets(ttk.Frame): # Address Label self.add = tk.StringVar() - self.add.set(_("Address: ") + data[0]) + self.add.set(f"{_("Address: ")}{data[0]}") self.DNS = tk.StringVar() - self.DNS.set(" DNS: " + data[1]) + self.DNS.set(f" DNS: {data[1]}") self.enp = tk.StringVar() - self.enp.set(_("Endpoint: ") + data[2]) + self.enp.set(f"{_("Endpoint: ")}{data[2]}") def label_empty(self): """ @@ -1078,7 +1045,7 @@ class FrameWidgets(ttk.Frame): self.select_tunnel = self.l_box.curselection() select_tl = self.l_box.get(self.select_tunnel[0]) check_call(["nmcli", "connection", "up", select_tl]) - wg_read = "/tmp/tlecdcwg/" + str(select_tl + ".conf") + wg_read = f"/tmp/tlecdcwg/{select_tl}.conf" with open(wg_read, "r", encoding="utf-8") as file: data = Tunnel.con_to_dict(file)