new format little fixes icons sort add policy add .desktop File install Part 2
This commit is contained in:
28
wg_func.py
28
wg_func.py
@ -8,7 +8,7 @@ from pathlib import Path
|
||||
from subprocess import check_call
|
||||
|
||||
font_color = '#4011a7'
|
||||
path_to_file = Path.home() / '.config/wire_py/wg_py'
|
||||
path_to_file = Path('/etc/wire_py/wg_py')
|
||||
|
||||
|
||||
def msg_window():
|
||||
@ -22,7 +22,7 @@ def msg_window():
|
||||
msg.geometry('%dx%d+%d+%d' % (msg.x_width, msg.y_height, msg.monitor_center_x, msg.monitor_center_y))
|
||||
msg.columnconfigure(0, weight=1)
|
||||
msg.configure(pady=20)
|
||||
msg.warning = tk.PhotoImage(file=r'icons/warning_64.png')
|
||||
msg.warning = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/64/warning.png')
|
||||
msg.i_warning = tk.Label(msg, image=msg.warning)
|
||||
msg.i_warning.grid(column=0, row=0)
|
||||
label = tk.Label(msg, text='Oh... no valid Wireguard File!\nPlease select a valid Wireguard File')
|
||||
@ -31,7 +31,7 @@ def msg_window():
|
||||
button = tk.Button(msg, text='OK', command=msg.destroy)
|
||||
button.config(padx=15, pady=5)
|
||||
button.grid(column=0, columnspan=2, row=1)
|
||||
wg_icon_2 = tk.PhotoImage(file=r'icons/wg-stop.png')
|
||||
wg_icon_2 = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_msg.png')
|
||||
msg.iconphoto(True, wg_icon_2)
|
||||
msg.winfo_toplevel()
|
||||
|
||||
@ -60,8 +60,8 @@ class StartStopBTN:
|
||||
self.lb_frame_btn_lbox = None
|
||||
self.wg_switch = None
|
||||
self.btn_stst = None
|
||||
self.wg_vpn_start = tk.PhotoImage(file=r'icons/wg-vpn-start-48.png')
|
||||
self.wg_vpn_stop = tk.PhotoImage(file=r'icons/wg-vpn-stop-48.png')
|
||||
self.wg_vpn_start = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-start.png')
|
||||
self.wg_vpn_stop = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-stop.png')
|
||||
|
||||
def button_stop(self):
|
||||
self.btn_stst = tk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
|
||||
@ -181,7 +181,7 @@ class ImportTunnel:
|
||||
|
||||
def wg_import_select(self):
|
||||
try:
|
||||
filepath = filedialog.askopenfilename(initialdir=Path.home(), title='Select Wireguard config File',
|
||||
filepath = filedialog.askopenfilename(initialdir=Path('/home/*/'), title='Select Wireguard config File',
|
||||
filetypes=[('WG config files', '*.conf')], )
|
||||
with open(filepath, 'r') as file:
|
||||
read = file.read()
|
||||
@ -190,17 +190,17 @@ class ImportTunnel:
|
||||
self.a = TunnelActiv.active()
|
||||
if 'PrivateKey = ' in read and 'PublicKey = ' in read:
|
||||
if len(path_split1) > 17:
|
||||
p1 = shutil.copy(filepath, Path.home() / 'tester/')
|
||||
p1 = shutil.copy(filepath, Path('/etc/wire_py/'))
|
||||
path_split = path_split1[len(path_split1) - 17:]
|
||||
os.rename(p1, Path.home() / 'tester/' / str(path_split))
|
||||
os.rename(p1, Path('/etc/wire_py') / str(path_split))
|
||||
|
||||
if self.a != '':
|
||||
check_call(['nmcli', 'connection', 'down', TunnelActiv.active()])
|
||||
ShowAddress.label_empty(self)
|
||||
check_call(['nmcli', 'connection', 'import', 'type', 'wireguard', 'file', Path.home() / 'tester' /
|
||||
check_call(['nmcli', 'connection', 'import', 'type', 'wireguard', 'file', 'etc', '/wire_py',
|
||||
path_split])
|
||||
else:
|
||||
shutil.copy(filepath, Path.home() / 'tester/')
|
||||
shutil.copy(filepath, Path('/etc/wire_py/'))
|
||||
if self.a != '':
|
||||
check_call(['nmcli', 'connection', 'down', TunnelActiv.active()])
|
||||
ShowAddress.label_empty(self)
|
||||
@ -214,7 +214,7 @@ class ImportTunnel:
|
||||
self.StrVar.set(self.a)
|
||||
GreenLabel.green_show_label(self)
|
||||
StartStopBTN.button_stop(self)
|
||||
wg_read = Path.home() / 'tester/' / str(self.a + '.conf')
|
||||
wg_read = Path('/etc/wire_py') / str(self.a + '.conf')
|
||||
with open(wg_read, 'r') as file:
|
||||
data = ConToDict.covert_to_dict(file)
|
||||
# Address Label
|
||||
@ -273,6 +273,8 @@ class OnOff:
|
||||
if Path.exists(path_to_file):
|
||||
self.selected_option.set(1)
|
||||
self.autoconnect_var.set('')
|
||||
if not Path.is_dir(Path('/etc/wire_py')):
|
||||
Path.mkdir(Path('/etc/wire_py'))
|
||||
self.auto_con = Path.read_text(path_to_file)
|
||||
else:
|
||||
self.wg_autostart.configure(state='disabled')
|
||||
@ -293,8 +295,8 @@ class ExportTunnels:
|
||||
tl = ListTunnels.tl_list()
|
||||
try:
|
||||
if len(tl) != 0:
|
||||
wg_tar = Path.home() / now_datetime
|
||||
p_to_conf = Path.home() / 'tester/'
|
||||
wg_tar = Path('/home/*/') / now_datetime
|
||||
p_to_conf = Path('/etc/wire_py/')
|
||||
shutil.make_archive(wg_tar, 'zip', p_to_conf)
|
||||
#if zip_full != 0:
|
||||
#print('Export erfolgraeich')
|
||||
|
Reference in New Issue
Block a user