little fixes
This commit is contained in:
parent
858e9f07fe
commit
607589d44a
49
.idea/workspace.xml
generated
49
.idea/workspace.xml
generated
@ -4,10 +4,13 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="add Options in">
|
||||
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="little fixes">
|
||||
<change afterPath="$PROJECT_DIR$/start_wg.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/wg_py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/wg_func.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_func.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/wg_py.xml" beforeDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -45,13 +48,15 @@
|
||||
"keyToString": {
|
||||
"ASKED_ADD_EXTERNAL_FILES": "true",
|
||||
"Python.main.executor": "Run",
|
||||
"Python.start_wg.executor": "Run",
|
||||
"Python.wg_func.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"git-widget-placeholder": "main",
|
||||
"last_opened_file_path": "/home/punix/Pyapps/wire-py",
|
||||
"settings.editor.selected.configurable": "preferences.lookFeel"
|
||||
}
|
||||
}</component>
|
||||
<component name="RunManager">
|
||||
<component name="RunManager" selected="Python.main">
|
||||
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
||||
<module name="wire-py" />
|
||||
<option name="ENV_FILES" value="" />
|
||||
@ -74,6 +79,33 @@
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="start_wg" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="wire-py" />
|
||||
<option name="ENV_FILES" value="" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/start_wg.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Python.start_wg" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
<component name="SharedIndexes">
|
||||
<attachedChunks>
|
||||
@ -291,7 +323,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1725567453540</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="26" />
|
||||
<task id="LOCAL-00026" summary="little fixes">
|
||||
<option name="closed" value="true" />
|
||||
<created>1725639633873</created>
|
||||
<option name="number" value="00026" />
|
||||
<option name="presentableId" value="LOCAL-00026" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1725639633873</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="27" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
@ -343,6 +383,7 @@
|
||||
<MESSAGE value="add if question and add autoconnect, autoconnect_var to class Filehandle in box_set no finish!" />
|
||||
<MESSAGE value="fixes on empty Listbox now is disable and now works autoconnect label with read and write, delete works now with read and write" />
|
||||
<MESSAGE value="add Frame widget 3 for Buttons and Listbox with Scrollbar. all Widgets new format delete works now of disable checkbox when Listbox empty (part two)" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="add Frame widget 3 for Buttons and Listbox with Scrollbar. all Widgets new format delete works now of disable checkbox when Listbox empty (part two)" />
|
||||
<MESSAGE value="little fixes" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="little fixes" />
|
||||
</component>
|
||||
</project>
|
22
main.py
22
main.py
@ -7,7 +7,6 @@ from wg_func import (TunnelActiv, ListTunnels, ImportTunnel, ConToDict, GreenLab
|
||||
FileHandle, ExportTunnels, OnOff)
|
||||
|
||||
font_color = '#4011a7'
|
||||
replacement = ''
|
||||
|
||||
|
||||
class MainWindow(tk.Tk):
|
||||
@ -35,8 +34,7 @@ class MainWindow(tk.Tk):
|
||||
|
||||
# App Menu
|
||||
self.app_menu = tk.Menu(self, borderwidth=0)
|
||||
for item in self.app_menu.keys():
|
||||
print(item, ': ', self.app_menu[item])
|
||||
|
||||
self.configure(menu=self.app_menu)
|
||||
self.app_menu.add_cascade(label='?')
|
||||
|
||||
@ -106,7 +104,6 @@ class FrameWidgets(ttk.Frame):
|
||||
# Listbox with Scrollbar
|
||||
def enable_check_box(event):
|
||||
tl = ListTunnels.tl_list()
|
||||
print(len(tl))
|
||||
if len(tl) != 0:
|
||||
self.wg_autostart.configure(state='normal')
|
||||
|
||||
@ -158,23 +155,6 @@ class FrameWidgets(ttk.Frame):
|
||||
self.l_box.delete(self.select_tunnel[0])
|
||||
os.remove(os.environ['HOME'] + '/tester/' + str(select_tl) + '.conf')
|
||||
|
||||
del_tl_read = open('wg_py.xml', 'r')
|
||||
if 'false ' in del_tl_read:
|
||||
first_word = 'false '
|
||||
else:
|
||||
first_word = 'true '
|
||||
|
||||
word_replace = ''
|
||||
# using the for loop
|
||||
for line in del_tl_read:
|
||||
line = line.strip()
|
||||
changes = line.replace(first_word + select_tl, '')
|
||||
word_replace = word_replace + changes + "\n"
|
||||
|
||||
del_tl_read.close()
|
||||
del_tl = open('wg_py.xml', 'w')
|
||||
del_tl.write(word_replace)
|
||||
del_tl.close()
|
||||
# for disable checkbox when Listbox empty
|
||||
tl = ListTunnels.tl_list()
|
||||
if len(tl) == 0:
|
||||
|
12
start_wg.py
Executable file
12
start_wg.py
Executable file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/python3
|
||||
from subprocess import check_call
|
||||
from pathlib import Path
|
||||
|
||||
home = Path.home()
|
||||
path_to_file = home / 'Pyapps/wire-py/wg_py'
|
||||
|
||||
with open(path_to_file, 'r') as file:
|
||||
for line in file.readlines():
|
||||
a_con = line[5:]
|
||||
check_call(['nmcli', 'connection', 'up', a_con])
|
||||
|
28
wg_func.py
28
wg_func.py
@ -213,9 +213,6 @@ class ImportTunnel:
|
||||
ShowAddress.show_data(self)
|
||||
file.close()
|
||||
os.system('nmcli con mod ' + str(self.a) + ' connection.autoconnect no')
|
||||
new_tl = open('wg_py.xml', 'a')
|
||||
new_tl.write('false ' + str(self.a) + '\n')
|
||||
new_tl.close()
|
||||
if 'PrivateKey = ' not in read:
|
||||
Message()
|
||||
except EOFError:
|
||||
@ -240,31 +237,16 @@ class FileHandle:
|
||||
self.select_tunnel = None
|
||||
|
||||
def box_set(self):
|
||||
word_replace = ''
|
||||
try:
|
||||
self.select_tunnel = self.l_box.curselection()
|
||||
select_tl = self.l_box.get(self.select_tunnel[0])
|
||||
if self.selected_option.get() == 0:
|
||||
set_on = open('wg_py.xml', 'r')
|
||||
# using the for loop
|
||||
for line in set_on:
|
||||
line = line.strip()
|
||||
changes = line.replace('true ' + select_tl, 'false ' + select_tl)
|
||||
os.system('nmcli con mod ' + str(self.auto_con) + ' connection.autoconnect no')
|
||||
word_replace = word_replace + changes + "\n"
|
||||
set_on.close()
|
||||
off = open('wg_py', 'w')
|
||||
off.close()
|
||||
if self.selected_option.get() >= 1:
|
||||
set_on = open('wg_py.xml', 'r')
|
||||
# using the for loop
|
||||
for line in set_on:
|
||||
line = line.strip()
|
||||
changes = line.replace('false ' + select_tl, 'true ' + select_tl)
|
||||
os.system('nmcli con mod ' + str(select_tl) + ' connection.autoconnect yes')
|
||||
word_replace = word_replace + changes + "\n"
|
||||
set_on = open('wg_py', 'w')
|
||||
set_on.write(select_tl)
|
||||
set_on.close()
|
||||
set_off = open('wg_py.xml', 'w')
|
||||
set_off.write(word_replace)
|
||||
set_off.close()
|
||||
|
||||
except IndexError:
|
||||
self.selected_option.set(1)
|
||||
@ -279,7 +261,7 @@ class OnOff(tk.Tk, FileHandle):
|
||||
|
||||
def on_off(self):
|
||||
a_connect = {}
|
||||
on_or_off = open('wg_py.xml', 'r')
|
||||
on_or_off = open('wg_py', 'r')
|
||||
for line in on_or_off.readlines():
|
||||
line_splitted = line.split()
|
||||
a_connect[line_splitted[0]] = line_splitted[1]
|
||||
|
Loading…
x
Reference in New Issue
Block a user