methods optimized-13:24
This commit is contained in:
parent
19d413ea97
commit
5fb4e68867
30
wirepy.py
30
wirepy.py
@ -554,7 +554,6 @@ class FrameWidgets(ttk.Frame):
|
||||
read = file.read()
|
||||
path_split = filepath.split("/")
|
||||
path_split1 = path_split[-1]
|
||||
self.a = Tunnel.active()
|
||||
|
||||
if "PrivateKey = " in read and "PublicKey = " in read and "Endpoint =" in read:
|
||||
with open(filepath, "r", encoding="utf-8") as file:
|
||||
@ -578,7 +577,7 @@ class FrameWidgets(ttk.Frame):
|
||||
os.rename(p1, f"/tmp/tlecdcwg/{path_split}")
|
||||
new_conf = f"/tmp/tlecdcwg/{path_split}"
|
||||
if self.a != "":
|
||||
check_call(["nmcli", "connection", "down", Tunnel.active()])
|
||||
check_call(["nmcli", "connection", "down", self.a])
|
||||
self.reset_fields()
|
||||
|
||||
subprocess.check_output(["nmcli", "connection", "import", "type",
|
||||
@ -589,7 +588,7 @@ class FrameWidgets(ttk.Frame):
|
||||
else:
|
||||
shutil.copy(filepath, "/tmp/tlecdcwg/")
|
||||
if self.a != "":
|
||||
check_call(["nmcli", "connection", "down", Tunnel.active()])
|
||||
check_call(["nmcli", "connection", "down", self.a])
|
||||
self.reset_fields()
|
||||
|
||||
subprocess.check_output(["nmcli", "connection", "import", "type",
|
||||
@ -670,11 +669,9 @@ class FrameWidgets(ttk.Frame):
|
||||
select_tl = self.l_box.get(select_tunnel[0])
|
||||
|
||||
if self.selected_option.get() == 0:
|
||||
with open(set_file, "r", encoding="utf-8") as set_f3:
|
||||
lines3 = set_f3.readlines()
|
||||
lines3[7] = "off\n"
|
||||
with open(set_file, "w", encoding="utf-8") as set_f3:
|
||||
set_f3.writelines(lines3)
|
||||
lines = Path(set_file).read_text(encoding="utf-8").splitlines(keepends=True)
|
||||
lines[7] = 'off\n'
|
||||
Path(set_file).write_text(''.join(lines), encoding="utf-8")
|
||||
|
||||
tl = Tunnel.list()
|
||||
|
||||
@ -682,11 +679,9 @@ class FrameWidgets(ttk.Frame):
|
||||
self.wg_autostart.configure(state="disabled")
|
||||
|
||||
if self.selected_option.get() >= 1:
|
||||
with open(set_file, "r", encoding="utf-8") as set_f3:
|
||||
lines3 = set_f3.readlines()
|
||||
lines3[7] = select_tl
|
||||
with open(set_file, "w", encoding="utf-8") as set_f3:
|
||||
set_f3.writelines(lines3)
|
||||
lines = Path(set_file).read_text(encoding="utf-8").splitlines(keepends=True)
|
||||
lines[7] = select_tl
|
||||
Path(set_file).write_text(''.join(lines), encoding="utf-8")
|
||||
|
||||
except IndexError:
|
||||
self.selected_option.set(1)
|
||||
@ -699,14 +694,13 @@ 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(set_file, "r", encoding="utf-8") as set_f4:
|
||||
lines4 = set_f4.readlines()
|
||||
lines = Path(set_file).read_text(encoding="utf-8").splitlines(keepends=True)
|
||||
|
||||
if lines4[7] != "off\n":
|
||||
print(f"{lines4[7]} starts automatically when the system starts.")
|
||||
if lines[7] != "off\n":
|
||||
print(f"{lines[7]} starts automatically when the system starts.")
|
||||
self.selected_option.set(1)
|
||||
self.autoconnect_var.set("")
|
||||
self.auto_con = lines4[7]
|
||||
self.auto_con = lines[7]
|
||||
|
||||
else:
|
||||
self.selected_option.set(0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user