rename wg_set to file_set fix LxTools.clean_files
This commit is contained in:
parent
d2a57b329b
commit
af702f297b
Binary file not shown.
@ -177,11 +177,11 @@ class LxTools(tk.Tk):
|
||||
f.write(logname)
|
||||
|
||||
@staticmethod
|
||||
def clean_files(dirname=None, path=None):
|
||||
def clean_files(dirname=None, file=None):
|
||||
if dirname != None:
|
||||
shutil.rmtree(dirname)
|
||||
if path != None:
|
||||
Path.unlink(f"{path}")
|
||||
if file != None:
|
||||
Path.unlink(file)
|
||||
|
||||
@staticmethod
|
||||
def if_tip(path):
|
||||
@ -242,7 +242,7 @@ class LxTools(tk.Tk):
|
||||
msg.winfo_toplevel()
|
||||
|
||||
@staticmethod
|
||||
def sigi(dirname=None, path=None):
|
||||
def sigi(dirname=None, file=None):
|
||||
"""
|
||||
function for clean up after break
|
||||
"""
|
||||
@ -264,12 +264,12 @@ class LxTools(tk.Tk):
|
||||
print(
|
||||
f"\nSignal {signame} {(signum)} received. => Aborting with exit code {exit_code}."
|
||||
)
|
||||
LxTools.clean_files(dirname)
|
||||
LxTools.clean_files(dirname, file)
|
||||
print("Breakdown by user...")
|
||||
sys.exit(exit_code)
|
||||
else:
|
||||
print(f"Signal {signum} received and ignored.")
|
||||
LxTools.clean_files(dirname)
|
||||
LxTools.clean_files(dirname, file)
|
||||
print("Process unexpectedly ended...")
|
||||
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
|
38
wirepy.py
38
wirepy.py
@ -68,7 +68,7 @@ class Wirepy(tk.Tk):
|
||||
|
||||
self.style = ttk.Style(self)
|
||||
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()
|
||||
if "light\n" in lines:
|
||||
self.tk.call("set_theme", "light")
|
||||
@ -120,17 +120,17 @@ class FrameWidgets(ttk.Frame):
|
||||
Set on or off in file
|
||||
"""
|
||||
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[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)
|
||||
|
||||
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[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)
|
||||
|
||||
def tooltip():
|
||||
@ -138,17 +138,17 @@ class FrameWidgets(ttk.Frame):
|
||||
Set True or False in file
|
||||
"""
|
||||
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[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)
|
||||
|
||||
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[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)
|
||||
|
||||
def info():
|
||||
@ -372,14 +372,14 @@ class FrameWidgets(ttk.Frame):
|
||||
pre_key = key[3]
|
||||
check_call(["nmcli", "connection", "delete", select_tl])
|
||||
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()
|
||||
if (
|
||||
select_tl == lines6[7].strip()
|
||||
and "off\n" not in lines6[7].strip()
|
||||
):
|
||||
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)
|
||||
self.selected_option.set(0)
|
||||
self.autoconnect_var.set(_("no Autoconnect"))
|
||||
@ -552,14 +552,14 @@ class FrameWidgets(ttk.Frame):
|
||||
if self.a != "" and self.a == select_tl:
|
||||
self.a = Tunnel.active()
|
||||
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()
|
||||
if (
|
||||
select_tl == lines5[7].strip()
|
||||
and "off\n" not in lines5[7].strip()
|
||||
):
|
||||
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)
|
||||
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])
|
||||
|
||||
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[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)
|
||||
|
||||
tl = Tunnel.list()
|
||||
@ -861,10 +861,10 @@ class FrameWidgets(ttk.Frame):
|
||||
self.wg_autostart.configure(state="disabled")
|
||||
|
||||
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[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)
|
||||
|
||||
except IndexError:
|
||||
@ -878,7 +878,7 @@ class FrameWidgets(ttk.Frame):
|
||||
Set (on), the selected tunnel is displayed in the label.
|
||||
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()
|
||||
|
||||
if lines4[7] != "off\n":
|
||||
@ -987,7 +987,7 @@ class FrameWidgets(ttk.Frame):
|
||||
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()
|
||||
if "light\n" in lines:
|
||||
self.lb_tunnel = ttk.Label(
|
||||
|
Loading…
x
Reference in New Issue
Block a user