04-06-2025_large_update #35

Merged
punix merged 61 commits from 04-06-2025_large_update into main 2025-06-04 19:34:40 +02:00
3 changed files with 25 additions and 25 deletions
Showing only changes of commit af702f297b - Show all commits

View File

@ -177,11 +177,11 @@ class LxTools(tk.Tk):
f.write(logname) f.write(logname)
@staticmethod @staticmethod
def clean_files(dirname=None, path=None): def clean_files(dirname=None, file=None):
if dirname != None: if dirname != None:
shutil.rmtree(dirname) shutil.rmtree(dirname)
if path != None: if file != None:
Path.unlink(f"{path}") Path.unlink(file)
@staticmethod @staticmethod
def if_tip(path): def if_tip(path):
@ -242,7 +242,7 @@ class LxTools(tk.Tk):
msg.winfo_toplevel() msg.winfo_toplevel()
@staticmethod @staticmethod
def sigi(dirname=None, path=None): def sigi(dirname=None, file=None):
""" """
function for clean up after break function for clean up after break
""" """
@ -264,12 +264,12 @@ class LxTools(tk.Tk):
print( print(
f"\nSignal {signame} {(signum)} received. => Aborting with exit code {exit_code}." f"\nSignal {signame} {(signum)} received. => Aborting with exit code {exit_code}."
) )
LxTools.clean_files(dirname) LxTools.clean_files(dirname, file)
print("Breakdown by user...") print("Breakdown by user...")
sys.exit(exit_code) sys.exit(exit_code)
else: else:
print(f"Signal {signum} received and ignored.") print(f"Signal {signum} received and ignored.")
LxTools.clean_files(dirname) LxTools.clean_files(dirname, file)
print("Process unexpectedly ended...") print("Process unexpectedly ended...")
signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGINT, signal_handler)

View File

@ -68,7 +68,7 @@ class Wirepy(tk.Tk):
self.style = ttk.Style(self) self.style = ttk.Style(self)
self.tk.call("source", f"{tcl_path}/water.tcl") self.tk.call("source", f"{tcl_path}/water.tcl")
with open(wg_set, "r", encoding="utf-8") as read_file: with open(set_file, "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:
self.tk.call("set_theme", "light") self.tk.call("set_theme", "light")
@ -120,17 +120,17 @@ class FrameWidgets(ttk.Frame):
Set on or off in file Set on or off in file
""" """
if set_update.get() == 1: if set_update.get() == 1:
with open(wg_set, "r", encoding="utf-8") as set_f2: with open(set_file, "r", encoding="utf-8") as set_f2:
lines2 = set_f2.readlines() lines2 = set_f2.readlines()
lines2[1] = "off\n" lines2[1] = "off\n"
with open(wg_set, "w", encoding="utf-8") as set_f2: with open(set_file, "w", encoding="utf-8") as set_f2:
set_f2.writelines(lines2) set_f2.writelines(lines2)
if set_update.get() == 0: if set_update.get() == 0:
with open(wg_set, "r", encoding="utf-8") as set_f2: with open(set_file, "r", encoding="utf-8") as set_f2:
lines2 = set_f2.readlines() lines2 = set_f2.readlines()
lines2[1] = "on\n" lines2[1] = "on\n"
with open(wg_set, "w", encoding="utf-8") as set_f2: with open(set_file, "w", encoding="utf-8") as set_f2:
set_f2.writelines(lines2) set_f2.writelines(lines2)
def tooltip(): def tooltip():
@ -138,17 +138,17 @@ class FrameWidgets(ttk.Frame):
Set True or False in file Set True or False in file
""" """
if set_tip.get(): if set_tip.get():
with open(wg_set, "r", encoding="utf-8") as set_f2: with open(set_file, "r", encoding="utf-8") as set_f2:
lines2 = set_f2.readlines() lines2 = set_f2.readlines()
lines2[5] = "False\n" lines2[5] = "False\n"
with open(wg_set, "w", encoding="utf-8") as set_f2: with open(set_file, "w", encoding="utf-8") as set_f2:
set_f2.writelines(lines2) set_f2.writelines(lines2)
else: else:
with open(wg_set, "r", encoding="utf-8") as set_f2: with open(set_file, "r", encoding="utf-8") as set_f2:
lines2 = set_f2.readlines() lines2 = set_f2.readlines()
lines2[5] = "True\n" lines2[5] = "True\n"
with open(wg_set, "w", encoding="utf-8") as set_f2: with open(set_file, "w", encoding="utf-8") as set_f2:
set_f2.writelines(lines2) set_f2.writelines(lines2)
def info(): def info():
@ -372,14 +372,14 @@ class FrameWidgets(ttk.Frame):
pre_key = key[3] pre_key = key[3]
check_call(["nmcli", "connection", "delete", select_tl]) check_call(["nmcli", "connection", "delete", select_tl])
self.l_box.delete(self.select_tunnel[0]) self.l_box.delete(self.select_tunnel[0])
with open(wg_set, "r", encoding="utf-8") as set_f6: with open(set_filele, "r", encoding="utf-8") as set_f6:
lines6 = set_f6.readlines() lines6 = set_f6.readlines()
if ( if (
select_tl == lines6[7].strip() select_tl == lines6[7].strip()
and "off\n" not in lines6[7].strip() and "off\n" not in lines6[7].strip()
): ):
lines6[7] = "off\n" lines6[7] = "off\n"
with open(wg_set, "w", encoding="utf-8") as set_f7: with open(set_file, "w", encoding="utf-8") as set_f7:
set_f7.writelines(lines6) set_f7.writelines(lines6)
self.selected_option.set(0) self.selected_option.set(0)
self.autoconnect_var.set(_("no Autoconnect")) self.autoconnect_var.set(_("no Autoconnect"))
@ -552,14 +552,14 @@ class FrameWidgets(ttk.Frame):
if self.a != "" and self.a == select_tl: if self.a != "" and self.a == select_tl:
self.a = Tunnel.active() self.a = Tunnel.active()
self.str_var.set(value=self.a) self.str_var.set(value=self.a)
with open(wg_set, "r", encoding="utf-8") as set_f5: with open(set_file, "r", encoding="utf-8") as set_f5:
lines5 = set_f5.readlines() lines5 = set_f5.readlines()
if ( if (
select_tl == lines5[7].strip() select_tl == lines5[7].strip()
and "off\n" not in lines5[7].strip() and "off\n" not in lines5[7].strip()
): ):
lines5[7] = new_a_connect lines5[7] = new_a_connect
with open(wg_set, "w", encoding="utf-8") as theme_set5: with open(set_file, "w", encoding="utf-8") as theme_set5:
theme_set5.writelines(lines5) theme_set5.writelines(lines5)
self.autoconnect_var.set(value=new_a_connect) self.autoconnect_var.set(value=new_a_connect)
@ -849,10 +849,10 @@ class FrameWidgets(ttk.Frame):
select_tl = self.l_box.get(select_tunnel[0]) select_tl = self.l_box.get(select_tunnel[0])
if self.selected_option.get() == 0: if self.selected_option.get() == 0:
with open(wg_set, "r", encoding="utf-8") as set_f3: with open(set_file, "r", encoding="utf-8") as set_f3:
lines3 = set_f3.readlines() lines3 = set_f3.readlines()
lines3[7] = "off\n" lines3[7] = "off\n"
with open(wg_set, "w", encoding="utf-8") as set_f3: with open(set_file, "w", encoding="utf-8") as set_f3:
set_f3.writelines(lines3) set_f3.writelines(lines3)
tl = Tunnel.list() tl = Tunnel.list()
@ -861,10 +861,10 @@ class FrameWidgets(ttk.Frame):
self.wg_autostart.configure(state="disabled") self.wg_autostart.configure(state="disabled")
if self.selected_option.get() >= 1: if self.selected_option.get() >= 1:
with open(wg_set, "r", encoding="utf-8") as set_f3: with open(set_file, "r", encoding="utf-8") as set_f3:
lines3 = set_f3.readlines() lines3 = set_f3.readlines()
lines3[7] = select_tl lines3[7] = select_tl
with open(wg_set, "w", encoding="utf-8") as set_f3: with open(set_file, "w", encoding="utf-8") as set_f3:
set_f3.writelines(lines3) set_f3.writelines(lines3)
except IndexError: except IndexError:
@ -878,7 +878,7 @@ class FrameWidgets(ttk.Frame):
Set (on), the selected tunnel is displayed in the label. Set (on), the selected tunnel is displayed in the label.
At (off) the label is first emptied then filled with No Autoconnect At (off) the label is first emptied then filled with No Autoconnect
""" """
with open(wg_set, "r", encoding="utf-8") as set_f4: with open(set_file, "r", encoding="utf-8") as set_f4:
lines4 = set_f4.readlines() lines4 = set_f4.readlines()
if lines4[7] != "off\n": if lines4[7] != "off\n":
@ -987,7 +987,7 @@ class FrameWidgets(ttk.Frame):
View activ Tunnel in color green or yellow View activ Tunnel in color green or yellow
""" """
with open(wg_set, "r", encoding="utf-8") as read_file: with open(set_file, "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:
self.lb_tunnel = ttk.Label( self.lb_tunnel = ttk.Label(