in delete replace open with Path
install fixes
This commit is contained in:
28
wg_func.py
28
wg_func.py
@ -2,7 +2,7 @@
|
||||
import os
|
||||
import shutil
|
||||
from datetime import datetime
|
||||
from tkinter import filedialog, ttk
|
||||
from tkinter import filedialog
|
||||
import tkinter as tk
|
||||
from pathlib import Path
|
||||
from subprocess import check_call
|
||||
@ -248,15 +248,12 @@ class FileHandle:
|
||||
select_tunnel = self.l_box.curselection()
|
||||
select_tl = self.l_box.get(select_tunnel[0])
|
||||
if self.selected_option.get() == 0:
|
||||
with open(path_to_file, 'w') as off:
|
||||
off.write('false ' + '\n')
|
||||
Path.unlink(path_to_file)
|
||||
tl = ListTunnels.tl_list()
|
||||
if len(tl) == 0:
|
||||
self.wg_autostart.configure(state='disabled')
|
||||
if self.selected_option.get() >= 1:
|
||||
with open(path_to_file, 'w') as set_on:
|
||||
set_on.write('true ' + select_tl)
|
||||
|
||||
Path.write_text(path_to_file, select_tl)
|
||||
except IndexError:
|
||||
self.selected_option.set(1)
|
||||
|
||||
@ -273,17 +270,14 @@ class OnOff:
|
||||
self.lb_frame_buttons = None
|
||||
|
||||
def on_off(self):
|
||||
with open(path_to_file, 'r') as file:
|
||||
for line in file.readlines():
|
||||
a_connect = line
|
||||
if 'true' in a_connect:
|
||||
self.selected_option.set(1)
|
||||
self.autoconnect_var.set('')
|
||||
self.auto_con = a_connect[5:]
|
||||
else:
|
||||
self.wg_autostart.configure(state='disabled')
|
||||
self.auto_con = 'no Autoconnect'
|
||||
|
||||
if Path.exists(path_to_file):
|
||||
self.selected_option.set(1)
|
||||
self.autoconnect_var.set('')
|
||||
self.auto_con = Path.read_text(path_to_file)
|
||||
else:
|
||||
self.wg_autostart.configure(state='disabled')
|
||||
self.auto_con = 'no Autoconnect'
|
||||
self.autoconnect_var.set('')
|
||||
self.autoconnect_var = tk.StringVar()
|
||||
self.autoconnect_var.set(self.auto_con)
|
||||
self.autoconnect = tk.Label(self, textvariable=self.autoconnect_var, fg='blue', padx=5)
|
||||
|
Reference in New Issue
Block a user