Compare commits

..

10 Commits

Author SHA1 Message Date
4c89488950 Merge pull request 'wire-py-reformat-14-09-2024' (#14) from wire-py-reformat-14-09-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/14
2024-09-14 23:31:00 +02:00
c0ae2d2b75 Merge pull request 'wire-py-reformat-14-08-2024' (#13) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/13
2024-09-05 22:22:00 +02:00
e4774abf19 Merge pull request 'fixes on empty Listbox now is disable and now works autoconnect label with read and write, delete works now with read and write' (#12) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/12
2024-09-04 20:55:51 +02:00
7b1e543428 Merge pull request 'add if question and add autoconnect, autoconnect_var to class Filehandle in box_set no finish!' (#11) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/11
2024-09-04 09:20:05 +02:00
6f83fc7162 Merge pull request 'wire-py-reformat-14-08-2024' (#10) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/10
2024-09-04 06:26:30 +02:00
b70400b456 Merge pull request 'wire-py-reformat-14-08-2024' (#9) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/9
2024-08-25 20:32:05 +02:00
e25bc154ea Merge pull request 'wire-py-reformat-14-08-2024' (#8) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/8
2024-08-23 18:00:19 +02:00
7aa3cd75fe Merge pull request 'Set Style to Clam' (#7) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/7
2024-08-21 22:52:27 +02:00
0b9eec8d1d Merge pull request 'add Class StartStopBTN to wg_func.py' (#6) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/6
2024-08-21 12:52:51 +02:00
b9083d4698 Merge pull request 'add file dict_to_address for' (#5) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/5
2024-08-21 12:00:18 +02:00
5 changed files with 40 additions and 46 deletions

View File

@ -4,7 +4,8 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="little fixes, add msg_window() &#10;function for Messagebox to show a tk.Toplevel()&#10;replace var = open() with: &#10;with open() as var:&#10;and remove by classes (tk.tk) and super()">
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="little fixes a labels when stop and start, installer first functions works">
<change afterPath="$PROJECT_DIR$/message.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/test.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/test2.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
@ -360,15 +361,7 @@
<option name="project" value="LOCAL" />
<updated>1725991610908</updated>
</task>
<task id="LOCAL-00030" summary="little fixes, add msg_window() &#10;function for Messagebox to show a tk.Toplevel()&#10;replace var = open() with: &#10;with open() as var:&#10;and remove by classes (tk.tk) and super()">
<option name="closed" value="true" />
<created>1726349168248</created>
<option name="number" value="00030" />
<option name="presentableId" value="LOCAL-00030" />
<option name="project" value="LOCAL" />
<updated>1726349168248</updated>
</task>
<option name="localTasksCounter" value="31" />
<option name="localTasksCounter" value="30" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -406,6 +399,7 @@
</component>
<component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="add class Frame and class Massage, delete funktion go 100%, add resize window" />
<MESSAGE value="add class Frame and class Massage, delete funktion go 100%, add resize window, add warning pic" />
<MESSAGE value="add class ListTunnels and class ImportTunnel, and add class ExportTunnels (ExportTunnels no finish)" />
<MESSAGE value="add Label Interface and Peer to new FrameWidget one and two. when import Tunnel then add to list works and remove of list when Tunnel delete.(with Label active on and off) &#10;add to class and methods open a avtive Tunnel when Wire-Py open, when import and start a Tunnel" />
@ -430,7 +424,6 @@
<MESSAGE value="little fixes" />
<MESSAGE value="little fixes replace os.system with check_call&#10;first steps in install Script add wg_start.service file" />
<MESSAGE value="little fixes a labels when stop and start, installer first functions works" />
<MESSAGE value="little fixes, add msg_window() &#10;function for Messagebox to show a tk.Toplevel()&#10;replace var = open() with: &#10;with open() as var:&#10;and remove by classes (tk.tk) and super()" />
<option name="LAST_COMMIT_MESSAGE" value="little fixes, add msg_window() &#10;function for Messagebox to show a tk.Toplevel()&#10;replace var = open() with: &#10;with open() as var:&#10;and remove by classes (tk.tk) and super()" />
<option name="LAST_COMMIT_MESSAGE" value="little fixes a labels when stop and start, installer first functions works" />
</component>
</project>

View File

@ -8,21 +8,20 @@ config_path = Path.home() / ".config" / "wire_py" / "wg_py"
start_file = f'''\
#!/usr/bin/python3
from subprocess import check_call
from pathlib import Path
path_to_file = Path.home() / '.config/wire_py/wg_py'
if Path.exists(path_to_file):
a_con = Path.read_text(path_to_file)
check_call(['nmcli', 'connection', 'up', a_con])
else:
pass
path_to_file = {str(config_path)!r}
with open(path_to_file, 'r') as file:
*_, line = file
a_con = line[5:]
check_call(['nmcli', 'connection', 'up', a_con])
'''
Path("start_wg.py").write_text(start_file)
config_path.parent.mkdir(exist_ok=True)
if not Path.exists(config_path):
config_path.write_text("false")
# Prompt the user for the sudo password
#sudo_password = getpass('Enter sudo password: ')

13
main.py
View File

@ -148,27 +148,26 @@ class FrameWidgets(ttk.Frame):
self.btn_i.grid(column=0, row=1, padx=15, pady=8)
def delete():
try:
self.select_tunnel = self.l_box.curselection()
select_tl = self.l_box.get(self.select_tunnel[0])
check_call(['nmcli', 'connection', 'delete', select_tl])
self.l_box.delete(self.select_tunnel[0])
Path.unlink(Path.home() / 'tester/' / str(select_tl + '.conf'))
os.remove(Path.home() / 'tester/' / str(select_tl + '.conf'))
path_to_file = Path.home() / '.config/wire_py/wg_py'
if Path.exists(path_to_file):
a_con = Path.read_text(path_to_file)
with open(path_to_file, 'r') as file2:
for line in file2.readlines():
a_con = line[5:]
if select_tl == a_con:
self.selected_option.set(0)
self.autoconnect_var.set('no Autoconnect')
Path.unlink(path_to_file)
# for disable checkbox when Listbox empty
tl = ListTunnels.tl_list()
if len(tl) == 0:
self.wg_autostart.configure(state='disabled')
Path.unlink(path_to_file)
with open(path_to_file, 'w') as file2:
file2.write('false')
if self.a != '' and self.a == select_tl:
self.StrVar.set(value='')

View File

@ -1,12 +1,9 @@
#!/usr/bin/python3
from subprocess import check_call
from pathlib import Path
path_to_file = Path.home() / '.config/wire_py/wg_py'
if Path.exists(path_to_file):
a_con = Path.read_text(path_to_file)
check_call(['nmcli', 'connection', 'up', a_con])
else:
pass
path_to_file = '/home/punix/.config/wire_py/wg_py'
with open(path_to_file, 'r') as file:
*_, line = file
a_con = line[5:]
check_call(['nmcli', 'connection', 'up', a_con])

View File

@ -2,7 +2,7 @@
import os
import shutil
from datetime import datetime
from tkinter import filedialog
from tkinter import filedialog, ttk
import tkinter as tk
from pathlib import Path
from subprocess import check_call
@ -248,12 +248,15 @@ class FileHandle:
select_tunnel = self.l_box.curselection()
select_tl = self.l_box.get(select_tunnel[0])
if self.selected_option.get() == 0:
Path.unlink(path_to_file)
with open(path_to_file, 'w') as off:
off.write('false ' + '\n')
tl = ListTunnels.tl_list()
if len(tl) == 0:
self.wg_autostart.configure(state='disabled')
if self.selected_option.get() >= 1:
Path.write_text(path_to_file, select_tl)
with open(path_to_file, 'w') as set_on:
set_on.write('true ' + select_tl)
except IndexError:
self.selected_option.set(1)
@ -270,14 +273,17 @@ class OnOff:
self.lb_frame_buttons = None
def on_off(self):
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('')
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'
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)