fix in converter and fix in import for no valid files

This commit is contained in:
Désiré Werner Menrath 2025-04-21 09:39:35 +02:00
parent c58a630e25
commit 8896f59efd
4 changed files with 22 additions and 17 deletions

View File

@ -179,6 +179,7 @@ class GiteaUpdate:
result = subprocess.call(to_down, shell=True) result = subprocess.call(to_down, shell=True)
if result == 0: if result == 0:
shutil.chown(str(Path.home()) + f"/{res}.zip", 1000, 1000) shutil.chown(str(Path.home()) + f"/{res}.zip", 1000, 1000)
# img_w, img_i, w_title, w_txt hand over # img_w, img_i, w_title, w_txt hand over
iw = r"/usr/share/icons/lx-icons/64/info.png" iw = r"/usr/share/icons/lx-icons/64/info.png"
ii = down_ok_image ii = down_ok_image
@ -187,6 +188,7 @@ class GiteaUpdate:
msg_window(iw, ii, wt, msg_t) msg_window(iw, ii, wt, msg_t)
else: else:
# img_w, img_i, w_title, w_txt hand over # img_w, img_i, w_title, w_txt hand over
iw = r"/usr/share/icons/lx-icons/64/error.png" iw = r"/usr/share/icons/lx-icons/64/error.png"
ii = down_not_ok_image ii = down_not_ok_image
@ -194,6 +196,7 @@ class GiteaUpdate:
msg_t = _("Download failed! Please try again") msg_t = _("Download failed! Please try again")
msg_window(iw, ii, wt, msg_t) msg_window(iw, ii, wt, msg_t)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
# img_w, img_i, w_title, w_txt hand over # img_w, img_i, w_title, w_txt hand over
iw = r"/usr/share/icons/lx-icons/64/error.png" iw = r"/usr/share/icons/lx-icons/64/error.png"
ii = down_not_ok_image ii = down_not_ok_image
@ -293,11 +296,9 @@ class Tunnel:
if "," in dns: if "," in dns:
dns = dns[:-1] dns = dns[:-1]
endpoint = final_dict["Endpoint"] endpoint = final_dict["Endpoint"]
try:
pre_key = final_dict.get("PresharedKey") pre_key = final_dict.get("PresharedKey")
if pre_key is None:
pre_key = final_dict.get("PreSharedKey") pre_key = final_dict.get("PreSharedKey")
finally:
pass
return address, dns, endpoint, pre_key return address, dns, endpoint, pre_key
@staticmethod @staticmethod
@ -344,7 +345,6 @@ class Tunnel:
shutil.copytree("/tmp/tlecdcwg/", "/tmp/wire_py", dirs_exist_ok=True) shutil.copytree("/tmp/tlecdcwg/", "/tmp/wire_py", dirs_exist_ok=True)
source = Path("/tmp/wire_py") source = Path("/tmp/wire_py")
shutil.make_archive(wg_tar, "zip", source) shutil.make_archive(wg_tar, "zip", source)
# shutil.chown(wg_tar + '.zip', 1000, 1000)
shutil.rmtree(source) shutil.rmtree(source)
with zipfile.ZipFile((wg_tar + ".zip"), "r") as zf: with zipfile.ZipFile((wg_tar + ".zip"), "r") as zf:
if len(zf.namelist()) != 0: if len(zf.namelist()) != 0:

View File

@ -8,6 +8,7 @@ from subprocess import check_call
path_to_file = Path(Path.home() / ".config/wire_py/settings") path_to_file = Path(Path.home() / ".config/wire_py/settings")
with open(path_to_file, "r", encoding="utf-8") as a_con: with open(path_to_file, "r", encoding="utf-8") as a_con:
# This funtion is for the independent autostart of the previously selected tunnel # This funtion is for the independent autostart of the previously selected tunnel
lines = a_con.readlines() lines = a_con.readlines()
a_con = lines[7].strip() a_con = lines[7].strip()

View File

@ -54,7 +54,6 @@ def signal_handler(signum, frame):
signame = signals_to_names_dict.get(signum, f"Unnamed signal: {signum}") signame = signals_to_names_dict.get(signum, f"Unnamed signal: {signum}")
# End program for certain signals, report to others only reception # End program for certain signals, report to others only reception
if signum in (signal.SIGINT, signal.SIGTERM): if signum in (signal.SIGINT, signal.SIGTERM):
exit_code = 1 exit_code = 1
print( print(
@ -99,7 +98,6 @@ class Wirepy(tk.Tk):
self.style = ttk.Style(self) self.style = ttk.Style(self)
self.tk.call("source", str(tcl_path) + "/water.tcl") self.tk.call("source", str(tcl_path) + "/water.tcl")
# self.tk.call('source', 'TK-Themes/water.tcl')
with open(wg_set, "r", encoding="utf-8") as read_file: with open(wg_set, "r", encoding="utf-8") as read_file:
lines = read_file.readlines() lines = read_file.readlines()
if "light\n" in lines: if "light\n" in lines:
@ -249,12 +247,12 @@ class FrameWidgets(ttk.Frame):
Remove Tool-Tip Remove Tool-Tip
""" """
window.my_tool_tip.destroy() window.my_tool_tip.destroy()
# App Menu # App Menu
self.version_lb = ttk.Label(self.menu_frame, text=VERSION) self.version_lb = ttk.Label(self.menu_frame, text=VERSION)
self.version_lb.config(font=("Ubuntu", 11), foreground="#00c4ff") self.version_lb.config(font=("Ubuntu", 11), foreground="#00c4ff")
self.version_lb.grid(column=0, row=0, rowspan=4, padx=10) self.version_lb.grid(column=0, row=0, rowspan=4, padx=10)
self.options_btn = ttk.Menubutton(self.menu_frame, text=_("Options")) self.options_btn = ttk.Menubutton(self.menu_frame, text=_("Options"))
self.options_btn.grid(column=1, columnspan=1, row=0) self.options_btn.grid(column=1, columnspan=1, row=0)
@ -301,6 +299,7 @@ class FrameWidgets(ttk.Frame):
# Update and Tooltip Label # Update and Tooltip Label
self.updates_lb = ttk.Label(self.menu_frame) self.updates_lb = ttk.Label(self.menu_frame)
self.updates_lb.grid(column=4, columnspan=3, row=0, padx=10) self.updates_lb.grid(column=4, columnspan=3, row=0, padx=10)
# View Checkbox for enable or disable Tooltip # View Checkbox for enable or disable Tooltip
if WG_TIPS: if WG_TIPS:
set_tip.set(value=False) set_tip.set(value=False)
@ -605,7 +604,6 @@ class FrameWidgets(ttk.Frame):
self.wg_autostart.configure(state="disabled") self.wg_autostart.configure(state="disabled")
# for disable checkbox when Listbox empty # for disable checkbox when Listbox empty
def empty_list_start_enter(event): def empty_list_start_enter(event):
""" """
The mouse moves into the entry widget The mouse moves into the entry widget
@ -908,6 +906,7 @@ class FrameWidgets(ttk.Frame):
self.selected_option = tk.IntVar() self.selected_option = tk.IntVar()
self.autoconnect_var = tk.StringVar() self.autoconnect_var = tk.StringVar()
self.autoconnect_var.set(self.auto_con) self.autoconnect_var.set(self.auto_con)
# Frame for Labels, Entry and Button # Frame for Labels, Entry and Button
self.autoconnect = ttk.Label( self.autoconnect = ttk.Label(
self.lb_frame3, textvariable=self.autoconnect_var, width=15 self.lb_frame3, textvariable=self.autoconnect_var, width=15
@ -1037,6 +1036,7 @@ class FrameWidgets(ttk.Frame):
) as readfile: ) as readfile:
p_key = readfile.readlines() p_key = readfile.readlines()
if pre_key in p_key or pre_key + "\n" in p_key: if pre_key in p_key or pre_key + "\n" in p_key:
# img_w, img_i, w_title, w_txt hand over # img_w, img_i, w_title, w_txt hand over
iw = r"/usr/share/icons/lx-icons/64/error.png" iw = r"/usr/share/icons/lx-icons/64/error.png"
ii = r"/usr/share/icons/lx-icons/48/wg_msg.png" ii = r"/usr/share/icons/lx-icons/48/wg_msg.png"
@ -1254,7 +1254,10 @@ class FrameWidgets(ttk.Frame):
) )
Path.chmod(wg_read, 0o600) Path.chmod(wg_read, 0o600)
if "PrivateKey = " and "Endpoint = " not in read: if ("PrivateKey = " in read) and ("Endpoint = " in read):
pass
else:
# img_w, img_i, w_title, w_txt hand over # img_w, img_i, w_title, w_txt hand over
iw = r"/usr/share/icons/lx-icons/64/error.png" iw = r"/usr/share/icons/lx-icons/64/error.png"
ii = r"/usr/share/icons/lx-icons/48/wg_msg.png" ii = r"/usr/share/icons/lx-icons/48/wg_msg.png"
@ -1264,12 +1267,12 @@ class FrameWidgets(ttk.Frame):
) )
msg_window(iw, ii, wt, msg_t) msg_window(iw, ii, wt, msg_t)
except EOFError: except EOFError as e:
pass print(e)
except TypeError: except TypeError as e:
pass print(e)
except FileNotFoundError: except FileNotFoundError as e:
pass print(e)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
print("Tunnel exist!") print("Tunnel exist!")
@ -1366,6 +1369,7 @@ class FrameWidgets(ttk.Frame):
""" """
shows data in the label shows data in the label
""" """
# Address Label # Address Label
self.address = ttk.Label( self.address = ttk.Label(
self.lb_frame, textvariable=self.add, foreground="#0071ff" self.lb_frame, textvariable=self.add, foreground="#0071ff"