Compare commits
51 Commits
Author | SHA1 | Date | |
---|---|---|---|
b68908eaef | |||
c4565ed169 | |||
485cfff457 | |||
1a0fc74a80 | |||
971c86c97f | |||
66dd27cc64 | |||
cf71eae7d3 | |||
1f80d5342c | |||
e719a1f23f | |||
a0da356cec | |||
ac87e0a4a7 | |||
6a3a982057 | |||
aab90eec70 | |||
511d5f72df | |||
ed93e99026 | |||
10c3b07053 | |||
e9814f2b60 | |||
c470783ff2 | |||
2fac03a927 | |||
03a7e48018 | |||
090842ab28 | |||
8a32065676 | |||
bc0d46d633 | |||
80c63eaf78 | |||
9eb99f0859 | |||
feb6217637 | |||
4bfc8c318e | |||
5f6aaa6cf1 | |||
0a5341fab7 | |||
414a36b436 | |||
fecbf2ab46 | |||
9d44e7ab42 | |||
18e042400c | |||
63ed0abc98 | |||
3102c685fd | |||
ec10f912ea | |||
96164eb132 | |||
a19f889950 | |||
de2929896d | |||
f9d4256679 | |||
a0b895438c | |||
4c89488950 | |||
c0ae2d2b75 | |||
e4774abf19 | |||
7b1e543428 | |||
6f83fc7162 | |||
b70400b456 | |||
e25bc154ea | |||
7aa3cd75fe | |||
0b9eec8d1d | |||
b9083d4698 |
@ -4,12 +4,20 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment=" - Fix a ConToDict Class when Endpoint not in Wireguard config file">
|
||||
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="- methods from class MainWindow move to class FrameWidgets for active color_label when theme change - optimize columnconfigure, rowconfigure in class MainWindow and FrameWidgets - add new Frame for Widgets on Bottom - optimize from tkinter * to from tkinter import filedialog, ttk, TclError">
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/128/error.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/128/info.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/256/error.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/256/info.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/32/error.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/32/info.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/48/error.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/48/info.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/64/error.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/64/info.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Changelog" beforeDir="false" afterPath="$PROJECT_DIR$/Changelog" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/testtheme.py" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/wg_func.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_func.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/install" beforeDir="false" afterPath="$PROJECT_DIR$/install" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/wg_func.py" beforeDir="false" afterPath="$PROJECT_DIR$/cls_mth_fc.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/wg_main.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_main.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@ -27,7 +35,7 @@
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||
<map>
|
||||
<entry key="$PROJECT_DIR$" value="main" />
|
||||
<entry key="$PROJECT_DIR$" value="1.11.0824" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
@ -48,26 +56,28 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"ASKED_ADD_EXTERNAL_FILES": "true",
|
||||
"Python.INSTALL.executor": "Run",
|
||||
"Python.install.executor": "Run",
|
||||
"Python.main.executor": "Run",
|
||||
"Python.messagebox.executor": "Run",
|
||||
"Python.start_wg.executor": "Run",
|
||||
"Python.testtheme.executor": "Run",
|
||||
"Python.wg_func.executor": "Run",
|
||||
"Python.wg_main.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"Shell Script.install.executor": "Run",
|
||||
"git-widget-placeholder": "main",
|
||||
"last_opened_file_path": "/home/punix/Pyapps/wire-py",
|
||||
"settings.editor.selected.configurable": "configurable.group.editor"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"ASKED_ADD_EXTERNAL_FILES": "true",
|
||||
"Python.INSTALL.executor": "Run",
|
||||
"Python.install.executor": "Run",
|
||||
"Python.main.executor": "Run",
|
||||
"Python.messagebox.executor": "Run",
|
||||
"Python.start_wg.executor": "Run",
|
||||
"Python.testtheme.executor": "Run",
|
||||
"Python.wg_func.executor": "Run",
|
||||
"Python.wg_main.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"Shell Script.install.executor": "Run",
|
||||
"Shell Script.run_as.executor": "Run",
|
||||
"git-widget-placeholder": "1.11.0824",
|
||||
"last_opened_file_path": "/home/punix/Pyapps/wire-py/lx-icons",
|
||||
"settings.editor.selected.configurable": "reference.settingsdialog.IDE.editor.colors"
|
||||
}
|
||||
}</component>
|
||||
}]]></component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$/lx-icons" />
|
||||
<recent name="$PROJECT_DIR$" />
|
||||
</key>
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
@ -131,7 +141,7 @@
|
||||
<component name="SharedIndexes">
|
||||
<attachedChunks>
|
||||
<set>
|
||||
<option value="bundled-python-sdk-0e3be3396995-c546a90a8094-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-242.23339.19" />
|
||||
<option value="bundled-python-sdk-8336bb23522e-31b6be0877a2-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-241.19072.16" />
|
||||
</set>
|
||||
</attachedChunks>
|
||||
</component>
|
||||
@ -144,62 +154,6 @@
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1723279982210</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00013" summary="In FrameWidged Class else Block StrVar, this resorts reference and variable assignment together">
|
||||
<option name="closed" value="true" />
|
||||
<created>1724401340512</created>
|
||||
<option name="number" value="00013" />
|
||||
<option name="presentableId" value="LOCAL-00013" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1724401340512</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00014" summary="add method init_and_report and label_empty to Class ShowAddress">
|
||||
<option name="closed" value="true" />
|
||||
<created>1724410630021</created>
|
||||
<option name="number" value="00014" />
|
||||
<option name="presentableId" value="LOCAL-00014" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1724410630021</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00015" summary="little fixes in Class Import">
|
||||
<option name="closed" value="true" />
|
||||
<created>1724416642213</created>
|
||||
<option name="number" value="00015" />
|
||||
<option name="presentableId" value="LOCAL-00015" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1724416642213</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00016" summary="fix label when laat Tunnel delete and fix Tuple error in delete and Start/Stop when listbox empty">
|
||||
<option name="closed" value="true" />
|
||||
<created>1724495688099</created>
|
||||
<option name="number" value="00016" />
|
||||
<option name="presentableId" value="LOCAL-00016" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1724495688099</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00017" summary="remove a ',' in DNS Name">
|
||||
<option name="closed" value="true" />
|
||||
<created>1724576599289</created>
|
||||
<option name="number" value="00017" />
|
||||
<option name="presentableId" value="LOCAL-00017" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1724576599289</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00018" summary="fix when Filname > 17 first copy file after rename">
|
||||
<option name="closed" value="true" />
|
||||
<created>1724593165879</created>
|
||||
<option name="number" value="00018" />
|
||||
<option name="presentableId" value="LOCAL-00018" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1724593165879</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00019" summary="add export Tunnel as zip">
|
||||
<option name="closed" value="true" />
|
||||
<created>1724610514657</created>
|
||||
<option name="number" value="00019" />
|
||||
<option name="presentableId" value="LOCAL-00019" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1724610514658</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00020" summary="columnconfigure on all widgets set">
|
||||
<option name="closed" value="true" />
|
||||
<created>1724778892233</created>
|
||||
@ -536,18 +490,69 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1729353898830</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="62" />
|
||||
<task id="LOCAL-00062" summary="- Optimize Class. Move to wg_main Import Start/StopBTN and Tooltip">
|
||||
<option name="closed" value="true" />
|
||||
<created>1729541504291</created>
|
||||
<option name="number" value="00062" />
|
||||
<option name="presentableId" value="LOCAL-00062" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1729541504292</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00063" summary="- Optimize Class. Move to wg_main Import Start/StopBTN and Tooltip">
|
||||
<option name="closed" value="true" />
|
||||
<created>1729541561434</created>
|
||||
<option name="number" value="00063" />
|
||||
<option name="presentableId" value="LOCAL-00063" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1729541561434</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00064" summary="- Optimize Class. Move to wg_main Import Start/StopBTN and Tooltip">
|
||||
<option name="closed" value="true" />
|
||||
<created>1729593628907</created>
|
||||
<option name="number" value="00064" />
|
||||
<option name="presentableId" value="LOCAL-00064" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1729593628908</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00065" summary="- Optimize Class and Tooltip">
|
||||
<option name="closed" value="true" />
|
||||
<created>1729938941026</created>
|
||||
<option name="number" value="00065" />
|
||||
<option name="presentableId" value="LOCAL-00065" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1729938941027</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00066" summary="- methods from class MainWindow move to class FrameWidgets for active color_label when theme change - optimize columnconfigure, rowconfigure in class MainWindow and FrameWidgets - add new Frame for Widgets on Bottom - optimize from tkinter * to from tkinter import filedialog, ttk, TclError">
|
||||
<option name="closed" value="true" />
|
||||
<created>1731097309468</created>
|
||||
<option name="number" value="00066" />
|
||||
<option name="presentableId" value="LOCAL-00066" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1731097309468</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00067" summary="- methods from class MainWindow move to class FrameWidgets for active color_label when theme change - optimize columnconfigure, rowconfigure in class MainWindow and FrameWidgets - add new Frame for Widgets on Bottom - optimize from tkinter * to from tkinter import filedialog, ttk, TclError">
|
||||
<option name="closed" value="true" />
|
||||
<created>1731097969343</created>
|
||||
<option name="number" value="00067" />
|
||||
<option name="presentableId" value="LOCAL-00067" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1731097969344</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00068" summary="- methods from class MainWindow move to class FrameWidgets for active color_label when theme change - optimize columnconfigure, rowconfigure in class MainWindow and FrameWidgets - add new Frame for Widgets on Bottom - optimize from tkinter * to from tkinter import filedialog, ttk, TclError">
|
||||
<option name="closed" value="true" />
|
||||
<created>1731098372497</created>
|
||||
<option name="number" value="00068" />
|
||||
<option name="presentableId" value="LOCAL-00068" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1731098372497</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="69" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="UnknownFeatures">
|
||||
<option featureType="com.intellij.fileTypeFactory" implementationName="*.policy" />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
<option name="OPEN_GENERIC_TABS">
|
||||
<map>
|
||||
<entry key="f9756e7d-0c5c-4b84-84e4-660314c46ea4" value="TOOL_WINDOW" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="TAB_STATES">
|
||||
<map>
|
||||
<entry key="MAIN">
|
||||
@ -558,7 +563,7 @@
|
||||
<entry key="branch">
|
||||
<value>
|
||||
<list>
|
||||
<option value="origin/wire-py-reformat-14-08-2024" />
|
||||
<option value="1.11.0824" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
@ -567,19 +572,11 @@
|
||||
</State>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="f9756e7d-0c5c-4b84-84e4-660314c46ea4">
|
||||
<value>
|
||||
<State />
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
||||
<MESSAGE value="set rights in install and a .conf a import Tunnel Filedialog Part 1 /home when open" />
|
||||
<MESSAGE value="fix set rights in install and a .conf a import Tunnel Filedialog Part 1 /home when open" />
|
||||
<MESSAGE value="fix a filedialog for hidden Files work install rollback to bash for start wirepy and wirepy rollback to bash" />
|
||||
<MESSAGE value="install rollback bash to py wirepy and wirepy rollback to py" />
|
||||
<MESSAGE value="fix install and .desktop File Tar works now for user home and filebrowser.askfilebrowser start now in user home" />
|
||||
<MESSAGE value="replace tar with zip and Check if Zip file is empty" />
|
||||
@ -602,20 +599,18 @@
|
||||
<MESSAGE value=" - Menu add - New Modern Dark and Light(default) Theme" />
|
||||
<MESSAGE value=" - Theme modify to water-theme - add ttk.Menubutton vor modern Menu and automatic theme and textvariable for color on font in menu" />
|
||||
<MESSAGE value=" - Add Options, Help, Update Label and Update Menubutton - Theme now separate Light and Dark" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value=" - Add Options, Help, Update Label and Update Menubutton - Theme now separate Light and Dark" />
|
||||
<MESSAGE value="- Optimize Class. Move to wg_main Import Start/StopBTN and Tooltip" />
|
||||
<MESSAGE value="- Optimize Class and Tooltip" />
|
||||
<MESSAGE value="- methods from class MainWindow move to class FrameWidgets for active color_label when theme change - optimize columnconfigure, rowconfigure in class MainWindow and FrameWidgets - add new Frame for Widgets on Bottom - optimize from tkinter * to from tkinter import filedialog, ttk, TclError" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="- methods from class MainWindow move to class FrameWidgets for active color_label when theme change - optimize columnconfigure, rowconfigure in class MainWindow and FrameWidgets - add new Frame for Widgets on Bottom - optimize from tkinter * to from tkinter import filedialog, ttk, TclError" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<breakpoints>
|
||||
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
||||
<url>file://$PROJECT_DIR$/wg_func.py</url>
|
||||
<line>341</line>
|
||||
<option name="timeStamp" value="8" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
||||
<url>file://$PROJECT_DIR$/wg_main.py</url>
|
||||
<line>273</line>
|
||||
<option name="timeStamp" value="11" />
|
||||
<url>file://$PROJECT_DIR$/start_wg.py</url>
|
||||
<line>1</line>
|
||||
<option name="timeStamp" value="2" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
|
73
Changelog
@ -3,19 +3,80 @@ My standard System: Linux Mint 22 Cinnamon
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- os import in wg_func replaced by other methods
|
||||
- Guide to menu '?' with pictures
|
||||
- In Gitea Readme enter text, images
|
||||
- Own filedialog for import
|
||||
- os import in cls_mth_fc.py replaced by other methods
|
||||
- If Wire-Py already runs, prevent further start
|
||||
- for loops with lists replaced by List Comprehensions
|
||||
- Keeping Classes Together
|
||||
- Update search after start of Wire-Py
|
||||
|
||||
### Added
|
||||
07-11-2024
|
||||
|
||||
- remove classes and add methods to class FrameWidgets (removed self errors)
|
||||
|
||||
|
||||
### Added
|
||||
10-11-2024
|
||||
|
||||
- Translate file de_De complete
|
||||
- new FrameWidget for rename Entry and rename Button
|
||||
|
||||
|
||||
### Added
|
||||
09-11-2024
|
||||
|
||||
- Move Tips Method in separate class for Tooltips in another Apps
|
||||
- Move Version Variable in main script
|
||||
- Edit Class GiteaUpdate for requests in api_down and download
|
||||
- Description on Class GiteaUpdate
|
||||
|
||||
|
||||
### Added
|
||||
08-11-2024
|
||||
|
||||
- Preparation for language translation part 1
|
||||
- separate folder for general icons
|
||||
- install edit for new dir lx-icons
|
||||
|
||||
|
||||
### Added
|
||||
08-11-2024
|
||||
|
||||
- methods from class MainWindow move to class FrameWidgets for active color_label when theme change
|
||||
- optimize columnconfigure, rowconfigure in class MainWindow and FrameWidgets
|
||||
- add new Frame for Widgets on Bottom
|
||||
- optimize from tkinter * to from tkinter import filedialog, ttk, TclError
|
||||
|
||||
|
||||
### Added
|
||||
07-11-2024
|
||||
|
||||
- remove classes and add methods to class FrameWidgets (removed self errors)
|
||||
|
||||
|
||||
### Added
|
||||
27-10-2024
|
||||
|
||||
- Add Autoconnect settings to settings.conf
|
||||
|
||||
|
||||
### Added
|
||||
26-10-2024
|
||||
|
||||
- Add run_as Bash script and open_gitea.py python script
|
||||
- Add Tooltip disable/enable
|
||||
- Rename settings to settings.conf for theme, updates and tooltip enable in one file
|
||||
|
||||
|
||||
### Added
|
||||
25-10-2024
|
||||
|
||||
- Optimize Class and Tooltip
|
||||
|
||||
|
||||
### Added
|
||||
21-10-2024
|
||||
|
||||
- Optimize Class. Move to wg_main Import Start/StopBTN and Tooltip
|
||||
- Optimize Class. Move to wg_main Import Start/StopBTN and Tooltip
|
||||
|
||||
|
||||
### Added
|
||||
|
272
cls_mth_fc.py
Executable file
@ -0,0 +1,272 @@
|
||||
""" Classes Method and functions for lx apps """
|
||||
|
||||
import gettext
|
||||
import locale
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import tkinter as tk
|
||||
import zipfile
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from tkinter import ttk
|
||||
import requests
|
||||
|
||||
APP = 'cls_mth_fc'
|
||||
LOCALE_DIR = "/usr/share/locale/"
|
||||
locale.bindtextdomain(APP, LOCALE_DIR)
|
||||
gettext.bindtextdomain(APP, LOCALE_DIR)
|
||||
gettext.textdomain(APP)
|
||||
_ = gettext.gettext
|
||||
|
||||
wg_set = Path('/etc/wire_py/settings.conf')
|
||||
_u = Path.read_text(Path('/tmp/_u'))
|
||||
|
||||
|
||||
class GiteaUpdate:
|
||||
"""
|
||||
Calling api_down requests the URL and the version of the running script.
|
||||
Example: version = 'v. 1.1.1.1' GiteaUpdate.api_down(http://example.de, version)
|
||||
|
||||
Calling download requests the download URL of the running script,
|
||||
the taskbar image for the “Download OK” window, the taskbar image for the
|
||||
“Download error” window and the variable res
|
||||
"""
|
||||
@staticmethod
|
||||
def api_down(update_api_url, version):
|
||||
try:
|
||||
response = requests.get(update_api_url)
|
||||
response_dict = response.json()
|
||||
response_dict = response_dict[0]
|
||||
with open(wg_set, 'r') as set_file:
|
||||
set_file = set_file.read()
|
||||
if 'on\n' in set_file:
|
||||
if version[3:] != response_dict['tag_name']:
|
||||
return response_dict['tag_name']
|
||||
else:
|
||||
return 'No Updates'
|
||||
else:
|
||||
return 'False'
|
||||
except requests.exceptions.ConnectionError:
|
||||
return 'No Internet Connection!'
|
||||
|
||||
@staticmethod
|
||||
def download(urld, down_ok_image, down_not_ok_image, res):
|
||||
try:
|
||||
to_down = 'wget -qP ' + str(_u) + ' ' + urld
|
||||
result = subprocess.call(to_down, shell=True)
|
||||
if result == 0:
|
||||
shutil.chown(str(_u) + f'/{res}.zip', 1000, 1000)
|
||||
"""img_w, img_i, w_title, w_txt hand over"""
|
||||
iw = r'/usr/share/icons/lx-icons/64/info.png'
|
||||
ii = down_ok_image
|
||||
wt = _('Download Successful')
|
||||
msg_t = _('Your zip file is in home directory')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
else:
|
||||
"""img_w, img_i, w_title, w_txt hand over"""
|
||||
iw = r'/usr/share/icons/lx-icons/64/error.png'
|
||||
ii = down_not_ok_image
|
||||
wt = _('Download error')
|
||||
msg_t = _('Download failed! Please try again')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
except subprocess.CalledProcessError:
|
||||
"""img_w, img_i, w_title, w_txt hand over"""
|
||||
iw = r'/usr/share/icons/lx-icons/64/error.png'
|
||||
ii = down_not_ok_image
|
||||
wt = _('Download error')
|
||||
msg_t = _('Download failed! No internet connection!')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
|
||||
def msg_window(img_w, img_i, w_title, w_txt, txt2=None, com=None):
|
||||
"""
|
||||
Function for different message windows for the user. with 4 arguments to be passed.
|
||||
To create messages with your own images, icons, and titles. As an alternative to Python Messagebox.
|
||||
Paths to images must be specified: r'/usr/share/icons/lx-icons/64/info.png'
|
||||
img_w = Image for Tk Window
|
||||
img_i = Image for Icon
|
||||
w_title = Windows Title
|
||||
w_txt = Text for Tk Window
|
||||
txt2 = Text for Button two
|
||||
com = function for Button command
|
||||
"""
|
||||
msg = tk.Toplevel()
|
||||
msg.resizable(width=False, height=False)
|
||||
msg.title(w_title)
|
||||
msg.configure(pady=15, padx=15)
|
||||
msg.img = tk.PhotoImage(file=img_w)
|
||||
msg.i_window = tk.Label(msg, image=msg.img)
|
||||
|
||||
label = tk.Label(msg, text=w_txt)
|
||||
|
||||
label.grid(column=1, row=0)
|
||||
|
||||
if txt2 is not None and com is not None:
|
||||
label.config(font=('Ubuntu', 11), padx=15, justify='left')
|
||||
msg.i_window.grid(column=0, row=0, sticky='nw')
|
||||
button2 = ttk.Button(msg, text=f'{txt2}', command=com, padding=4)
|
||||
button2.grid(column=0, row=1, sticky='e', columnspan=2)
|
||||
button = ttk.Button(msg, text='OK', command=msg.destroy, padding=4)
|
||||
button.grid(column=0, row=1, sticky='w', columnspan=2)
|
||||
|
||||
else:
|
||||
label.config(font=('Ubuntu', 11), padx=15)
|
||||
msg.i_window.grid(column=0, row=0)
|
||||
button = ttk.Button(msg, text='OK', command=msg.destroy, padding=4)
|
||||
button.grid(column=0, columnspan=2, row=1)
|
||||
|
||||
img_i = tk.PhotoImage(file=img_i)
|
||||
msg.iconphoto(True, img_i)
|
||||
msg.columnconfigure(0, weight=1)
|
||||
msg.rowconfigure(0, weight=1)
|
||||
msg.winfo_toplevel()
|
||||
|
||||
|
||||
class Tunnel:
|
||||
"""
|
||||
Class of Methods for Wire-Py
|
||||
"""
|
||||
|
||||
"""
|
||||
The config file is packed into a dictionary,
|
||||
to display the values Address , DNS and Peer in the labels
|
||||
"""
|
||||
@classmethod
|
||||
def con_to_dict(cls, file):
|
||||
|
||||
dictlist = []
|
||||
for lines in file.readlines():
|
||||
line_plit = lines.split()
|
||||
dictlist = dictlist + line_plit
|
||||
dictlist.remove('[Interface]')
|
||||
dictlist.remove('[Peer]')
|
||||
for items in dictlist:
|
||||
if items == '=':
|
||||
dictlist.remove(items)
|
||||
|
||||
''' Here is the beginning (Loop) of convert List to Dictionary '''
|
||||
for _ in dictlist:
|
||||
a = [dictlist[0], dictlist[1]]
|
||||
b = [dictlist[2], dictlist[3]]
|
||||
c = [dictlist[4], dictlist[5]]
|
||||
d = [dictlist[6], dictlist[7]]
|
||||
e = [dictlist[8], dictlist[9]]
|
||||
f = [dictlist[10], dictlist[11]]
|
||||
g = [dictlist[12], dictlist[13]]
|
||||
h = [dictlist[14], dictlist[15]]
|
||||
new_list = [a, b, c, d, e, f, g, h]
|
||||
final_dict = {}
|
||||
for elements in new_list:
|
||||
final_dict[elements[0]] = elements[1]
|
||||
|
||||
''' end... result a Dictionary '''
|
||||
|
||||
address = final_dict['Address']
|
||||
dns = final_dict['DNS']
|
||||
if ',' in dns:
|
||||
dns = dns[:-1]
|
||||
endpoint = final_dict['Endpoint']
|
||||
if 'PresharedKey' in final_dict:
|
||||
pre_key = final_dict['PresharedKey']
|
||||
else:
|
||||
pre_key = final_dict['PreSharedKey']
|
||||
return address, dns, endpoint, pre_key
|
||||
|
||||
"""
|
||||
Shows the Active Tunnel
|
||||
"""
|
||||
@staticmethod
|
||||
def active():
|
||||
|
||||
active = os.popen('nmcli con show --active | grep -iPo "(.*)(wireguard)"').read().split()
|
||||
if not active:
|
||||
active = ''
|
||||
else:
|
||||
active = active[0]
|
||||
|
||||
return active
|
||||
|
||||
"""
|
||||
Shows all existing Wireguard tunnels
|
||||
"""
|
||||
@staticmethod
|
||||
def list():
|
||||
wg_s = os.popen('nmcli con show | grep -iPo "(.*)(wireguard)"').read().split()
|
||||
|
||||
''' tl = Tunnel list # Show of 4.Element in list '''
|
||||
tl = wg_s[::3]
|
||||
return tl
|
||||
|
||||
"""
|
||||
This will export the tunnels.
|
||||
A zipfile with current date and time is created
|
||||
in the user's home directory with correct right
|
||||
"""
|
||||
@staticmethod
|
||||
def export():
|
||||
_u1 = str(_u[6:])
|
||||
now_time = datetime.now()
|
||||
now_datetime = now_time.strftime('wg-exp-' + '%m-%d-%Y' + '-' + '%H:%M')
|
||||
tl = Tunnel.list()
|
||||
|
||||
try:
|
||||
if len(tl) != 0:
|
||||
wg_tar = str(_u) + '/' + now_datetime
|
||||
shutil.copytree('/etc/wire_py', '/tmp/wire_py', dirs_exist_ok=True)
|
||||
source = Path('/tmp/wire_py')
|
||||
Path.unlink(Path(source) / 'wg_py', missing_ok=True)
|
||||
Path.unlink(Path(source) / '.keys', missing_ok=True)
|
||||
Path.unlink(Path(source) / 'settings.conf', missing_ok=True)
|
||||
shutil.make_archive(wg_tar, 'zip', source)
|
||||
shutil.chown(wg_tar + '.zip', 1000, 1000)
|
||||
shutil.rmtree(source)
|
||||
with zipfile.ZipFile((wg_tar + '.zip'), 'r') as zf:
|
||||
if len(zf.namelist()) != 0:
|
||||
|
||||
"""img_w, img_i, w_title, w_txt hand over"""
|
||||
iw = r'/usr/share/icons/lx-icons/64/info.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_vpn.png'
|
||||
wt = _('Export Successful')
|
||||
msg_t = _('Your zip file is in home directory')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
else:
|
||||
|
||||
"""img_w, img_i, w_title, w_txt hand over"""
|
||||
iw = r'/usr/share/icons/lx-icons/64/error.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = _('Export error')
|
||||
msg_t = _('Export failed! Please try again')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
else:
|
||||
|
||||
"""img_w, img_i, w_title, w_txt hand over"""
|
||||
iw = r'/usr/share/icons/lx-icons/64/info.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = _('Select tunnel')
|
||||
msg_t = _('Please first import tunnel')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
|
||||
class Tipi:
|
||||
"""
|
||||
Class for Tooltip setting write in File
|
||||
Calling request path to file
|
||||
"""
|
||||
@staticmethod
|
||||
def if_tip(path):
|
||||
with open(path, 'r') as set_file2:
|
||||
lines2 = set_file2.readlines()
|
||||
if 'False\n' in lines2:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
wg_tips = Tipi.if_tip(wg_set)
|
28
install
@ -7,10 +7,11 @@ BLUE='\033[30;1;34m'
|
||||
install_file_with(){
|
||||
clear
|
||||
sudo apt install python3-tk && \
|
||||
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py /usr/bin/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && sudo cp -u settings theme /etc/wire_py/ && \
|
||||
sudo cp -uR wp-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo cp -u wg_main.py start_wg.py cls_mth_fc.py wirepy.py run_as open_gitea.py /usr/bin/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && sudo cp -u settings.conf /etc/wire_py/ && \
|
||||
sudo cp -uR wp-icons lx-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
|
||||
sudo cp -u languages/de/*.mo /usr/share/locale/de/LC_MESSAGES/ && \
|
||||
sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \
|
||||
sudo cp -u org.wirepy.policy /usr/share/polkit-1/actions/ && \
|
||||
sudo cp -u Wire-Py.desktop /usr/share/applications/ && \
|
||||
@ -21,10 +22,11 @@ install_file_with(){
|
||||
install_arch_d(){
|
||||
clear
|
||||
sudo pacman -S --noconfirm tk python3 python-requests && \
|
||||
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py /usr/bin/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && sudo cp -u settings theme /etc/wire_py/ && \
|
||||
sudo cp -uR wp-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo cp -u wg_main.py start_wg.py cls_mth_fc.py wirepy.py run_as open_gitea.py /usr/bin/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && sudo cp -u settings.conf /etc/wire_py/ && \
|
||||
sudo cp -uR wp-icons lx-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
|
||||
sudo cp -u languages/de/*.mo /usr/share/locale/de/LC_MESSAGES/ && \
|
||||
sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \
|
||||
sudo cp -u org.wirepy.policy /usr/share/polkit-1/actions/ && \
|
||||
sudo cp -u Wire-Py.desktop /usr/share/applications/ && \
|
||||
@ -89,10 +91,11 @@ elif grep -i 'fedora' /etc/os-release > /dev/null 2>&1
|
||||
if ! which python3-tkinter &> /dev/null
|
||||
then sudo dnf install python3-tkinter -y
|
||||
|
||||
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py /usr/bin/ && \
|
||||
sudo cp -u wg_main.py start_wg.py cls_mth_fc.py wirepy.py run_as open_gitea.py /usr/bin/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && \
|
||||
sudo cp -u settings theme /etc/wire_py/ && \
|
||||
sudo cp -uR wp-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo cp -u settings.conf /etc/wire_py/ && \
|
||||
sudo cp -u languages/de/*.mo /usr/share/locale/de/LC_MESSAGES/ && \
|
||||
sudo cp -uR wp-icons lx-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
|
||||
sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \
|
||||
sudo cp -u org.wirepy.policy /usr/share/polkit-1/actions/ && \
|
||||
@ -105,10 +108,11 @@ elif grep -i 'suse' /etc/os-release > /dev/null 2>&1
|
||||
then
|
||||
if ! which python311-tk &> /dev/null
|
||||
then sudo zypper install python311-tk
|
||||
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py /usr/bin/ && \
|
||||
sudo cp -u wg_main.py start_wg.py cls_mth_fc.py wirepy.py run_as open_gitea.py /usr/bin/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && \
|
||||
sudo cp -u settings theme /etc/wire_py/ && \
|
||||
sudo cp -uR wp-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo cp -u settings.conf /etc/wire_py/ && \
|
||||
sudo cp -u languages/de/*.mo /usr/share/locale/de/LC_MESSAGES/ && \
|
||||
sudo cp -uR wp-icons lx-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
|
||||
sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \
|
||||
sudo cp -u org.wirepy.policy /usr/share/polkit-1/actions/ && \
|
||||
|
BIN
languages/de/cls_mth_fc.mo
Normal file
BIN
languages/de/wirepy.mo
Normal file
BIN
lx-icons/128/error.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
lx-icons/128/info.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
lx-icons/256/error.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
lx-icons/256/info.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
lx-icons/32/error.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
lx-icons/32/info.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
lx-icons/48/error.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
lx-icons/48/info.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
lx-icons/64/error.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
lx-icons/64/info.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
5
open_gitea.py
Executable file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import webbrowser
|
||||
|
||||
webbrowser.open('https://git.ilunix.de/punix/Wire-Py')
|
8
settings.conf
Normal file
@ -0,0 +1,8 @@
|
||||
[UPDATES]
|
||||
on
|
||||
[THEME]
|
||||
light
|
||||
[TOOLTIP]
|
||||
True
|
||||
[AUTOSTART ON]
|
||||
off
|
14
start_wg.py
@ -2,11 +2,13 @@
|
||||
from subprocess import check_call
|
||||
from pathlib import Path
|
||||
|
||||
path_to_file = Path('/etc/wire_py/wg_py')
|
||||
path_to_file = Path('/etc/wire_py/settings.conf')
|
||||
|
||||
if Path.exists(path_to_file):
|
||||
a_con = Path.read_text(path_to_file)
|
||||
check_call(['nmcli', 'connection', 'up', a_con])
|
||||
else:
|
||||
pass
|
||||
with open(path_to_file, 'r') as a_con:
|
||||
lines = a_con.readlines()
|
||||
a_con = lines[7].strip()
|
||||
if a_con != 'off':
|
||||
check_call(['nmcli', 'connection', 'up', a_con])
|
||||
else:
|
||||
pass
|
||||
|
||||
|
27
testtheme.py
@ -1,27 +0,0 @@
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
|
||||
root = tk.Tk()
|
||||
|
||||
# Pack a big frame so, it behaves like the window background
|
||||
big_frame = ttk.Frame(root)
|
||||
big_frame.pack(fill="both", expand=True)
|
||||
|
||||
# Set the initial theme
|
||||
root.tk.call("source", "TK-Themes/azure.tcl")
|
||||
root.tk.call("set_theme", "light")
|
||||
|
||||
def change_theme():
|
||||
# NOTE: The theme's real name is azure-<mode>
|
||||
if root.tk.call("ttk::style", "theme", "use") == "azure-dark":
|
||||
# Set light theme
|
||||
root.tk.call("set_theme", "light")
|
||||
else:
|
||||
# Set dark theme
|
||||
root.tk.call("set_theme", "dark")
|
||||
|
||||
# Remember, you have to use ttk widgets
|
||||
button = ttk.Button(big_frame, text="Change theme!", command=change_theme)
|
||||
button.pack()
|
||||
|
||||
root.mainloop()
|
400
wg_func.py
@ -1,400 +0,0 @@
|
||||
""" Wireguard Classes and Method for Wire-Py """
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import tkinter as tk
|
||||
import zipfile
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from subprocess import check_call
|
||||
from tkinter import ttk
|
||||
import requests
|
||||
|
||||
|
||||
''' 1 = 1. Year, 09 = Month of the Year, 2924 = Day and Year of the Year '''
|
||||
version = 'v. 1.10.2124'
|
||||
|
||||
path_to_file = Path('/etc/wire_py/wg_py')
|
||||
path_to_file2 = Path('/etc/wire_py/settings')
|
||||
path_to_file3 = Path('/etc/wire_py/theme')
|
||||
_u = Path.read_text(Path('/tmp/_u'))
|
||||
|
||||
UPDATE_API_URL = 'https://git.ilunix.de/api/v1/repos/punix/Wire-Py/releases'
|
||||
|
||||
|
||||
class WirePyUpdate:
|
||||
@staticmethod
|
||||
def api_down():
|
||||
try:
|
||||
response = requests.get(UPDATE_API_URL)
|
||||
response_dict = response.json()
|
||||
response_dict = response_dict[0]
|
||||
with open(path_to_file2, 'r') as set_file:
|
||||
set_file = set_file.read()
|
||||
if 'Update on' in set_file:
|
||||
if version[3:] != response_dict['tag_name']:
|
||||
return response_dict['tag_name']
|
||||
else:
|
||||
return 'No Updates'
|
||||
else:
|
||||
return 'False'
|
||||
except requests.exceptions.ConnectionError:
|
||||
return 'No Internet Connection!'
|
||||
|
||||
@staticmethod
|
||||
def download():
|
||||
try:
|
||||
url = f'https://git.ilunix.de/punix/Wire-Py/archive/{res}.zip'
|
||||
to_down = 'wget -qP ' + str(_u) + ' ' + url
|
||||
result = subprocess.call(to_down, shell=True)
|
||||
if result == 0:
|
||||
shutil.chown(str(_u) + f'/{res}.zip', 1000, 1000)
|
||||
"""img_w, img_i, w_title, w_txt hand over"""
|
||||
iw = r'/usr/share/icons/wp-icons/64/info.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_vpn.png'
|
||||
wt = 'Download Successful'
|
||||
msg_t = 'Your zip file is in home directory'
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
else:
|
||||
"""img_w, img_i, w_title, w_txt hand over"""
|
||||
iw = r'/usr/share/icons/wp-icons/64/error.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Download error'
|
||||
msg_t = 'Download failed! Please try again'
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
except subprocess.CalledProcessError:
|
||||
"""img_w, img_i, w_title, w_txt hand over"""
|
||||
iw = r'/usr/share/icons/wp-icons/64/error.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Download error'
|
||||
msg_t = 'Download failed! No internet connection!'
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
|
||||
res = WirePyUpdate.api_down()
|
||||
|
||||
|
||||
def msg_window(img_w, img_i, w_title, w_txt):
|
||||
"""
|
||||
Function for different message windows for the user. with 4 arguments to be passed.
|
||||
To create messages with your own images, icons, and titles. As an alternative to Python Messagebox.
|
||||
Paths to images must be specified: r'/usr/share/icons/wp-icons/64/info.png'
|
||||
img_w = Image for Tk Window
|
||||
img_i = Image for Icon
|
||||
w_title = Windows Title
|
||||
w_txt = Text for Tk Window
|
||||
"""
|
||||
|
||||
msg = tk.Toplevel()
|
||||
msg.resizable(width=False, height=False)
|
||||
msg.title(w_title)
|
||||
msg.configure(pady=15, padx=15)
|
||||
msg.img = tk.PhotoImage(file=img_w)
|
||||
msg.i_window = tk.Label(msg, image=msg.img)
|
||||
msg.i_window.grid(column=0, row=0)
|
||||
label = tk.Label(msg, text=w_txt)
|
||||
label.config(font=('Ubuntu', 11), padx=15)
|
||||
label.grid(column=1, row=0)
|
||||
button = ttk.Button(msg, text='OK', command=msg.destroy, padding=4)
|
||||
button.config()
|
||||
button.grid(column=0, columnspan=2, row=1)
|
||||
img_i = tk.PhotoImage(file=img_i)
|
||||
msg.iconphoto(True, img_i)
|
||||
msg.columnconfigure(0, weight=1)
|
||||
msg.rowconfigure(0, weight=1)
|
||||
msg.winfo_toplevel()
|
||||
|
||||
|
||||
class GreenLabel:
|
||||
"""
|
||||
Show the active tunnel in green in the label
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.StrVar = None
|
||||
self.lb_tunnel = None
|
||||
|
||||
def green_show_label(self):
|
||||
with open(path_to_file3, 'r') as read_file:
|
||||
if 'light' in read_file:
|
||||
self.lb_tunnel = ttk.Label(self, textvariable=self.StrVar, foreground='green')
|
||||
|
||||
else:
|
||||
self.lb_tunnel = ttk.Label(self, textvariable=self.StrVar, foreground='yellow')
|
||||
|
||||
self.lb_tunnel.config(font=('Ubuntu', 11, 'bold'))
|
||||
self.lb_tunnel.grid(column=2, padx=10, row=1)
|
||||
self.columnconfigure(2, weight=1)
|
||||
self.rowconfigure(0, weight=1)
|
||||
|
||||
def columnconfigure(self, param, weight):
|
||||
pass
|
||||
|
||||
def rowconfigure(self, param, weight):
|
||||
pass
|
||||
|
||||
|
||||
class ConToDict:
|
||||
"""
|
||||
The config file is packed into a dictionary,
|
||||
to display the values Address , DNS and Peer in the labels
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def covert_to_dict(cls, file):
|
||||
|
||||
dictlist = []
|
||||
for lines in file.readlines():
|
||||
line_plit = lines.split()
|
||||
dictlist = dictlist + line_plit
|
||||
dictlist.remove('[Interface]')
|
||||
dictlist.remove('[Peer]')
|
||||
for items in dictlist:
|
||||
if items == '=':
|
||||
dictlist.remove(items)
|
||||
|
||||
''' Here is the beginning (Loop) of convert List to Dictionary '''
|
||||
for _ in dictlist:
|
||||
a = [dictlist[0], dictlist[1]]
|
||||
b = [dictlist[2], dictlist[3]]
|
||||
c = [dictlist[4], dictlist[5]]
|
||||
d = [dictlist[6], dictlist[7]]
|
||||
e = [dictlist[8], dictlist[9]]
|
||||
f = [dictlist[10], dictlist[11]]
|
||||
g = [dictlist[12], dictlist[13]]
|
||||
h = [dictlist[14], dictlist[15]]
|
||||
new_list = [a, b, c, d, e, f, g, h]
|
||||
final_dict = {}
|
||||
for elements in new_list:
|
||||
final_dict[elements[0]] = elements[1]
|
||||
|
||||
''' end... result a Dictionary '''
|
||||
|
||||
address = final_dict['Address']
|
||||
dns = final_dict['DNS']
|
||||
if ',' in dns:
|
||||
dns = dns[:-1]
|
||||
endpoint = final_dict['Endpoint']
|
||||
if 'PresharedKey' in final_dict:
|
||||
pre_key = final_dict['PresharedKey']
|
||||
else:
|
||||
pre_key = final_dict['PreSharedKey']
|
||||
return address, dns, endpoint, pre_key
|
||||
|
||||
|
||||
class TunnelActiv:
|
||||
"""
|
||||
Shows the Active Tunnel
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def active():
|
||||
|
||||
active = os.popen('nmcli con show --active | grep -iPo "(.*)(wireguard)"').read().split()
|
||||
if not active:
|
||||
active = ''
|
||||
else:
|
||||
active = active[0]
|
||||
|
||||
return active
|
||||
|
||||
|
||||
class ShowAddress:
|
||||
"""
|
||||
Displays the value address, DNS and peer in the labels
|
||||
or empty it again
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.lb_frame2 = None
|
||||
self.lb_frame = None
|
||||
self.endpoint = None
|
||||
self.dns = None
|
||||
self.address = None
|
||||
self.enp = None
|
||||
self.DNS = None
|
||||
self.add = None
|
||||
|
||||
def init_and_report(self, data=None):
|
||||
""" Address Label """
|
||||
self.add = tk.StringVar()
|
||||
self.add.set('Address: ' + data[0])
|
||||
self.DNS = tk.StringVar()
|
||||
self.DNS.set(' DNS: ' + data[1])
|
||||
self.enp = tk.StringVar()
|
||||
self.enp.set('Endpoint: ' + data[2])
|
||||
|
||||
def label_empty(self):
|
||||
self.add.set('')
|
||||
self.DNS.set('')
|
||||
self.enp.set('')
|
||||
|
||||
def show_data(self):
|
||||
""" Address Label """
|
||||
self.address = ttk.Label(self.lb_frame, textvariable=self.add, foreground='#0071ff')
|
||||
self.address.grid(column=0, row=5, sticky='w', padx=10, pady=6)
|
||||
self.address.config(font=('Ubuntu', 9))
|
||||
|
||||
''' DNS Label '''
|
||||
self.dns = ttk.Label(self.lb_frame, textvariable=self.DNS, foreground='#0071ff')
|
||||
self.dns.grid(column=0, row=7, sticky='w', padx=10, pady=6)
|
||||
self.dns.config(font=('Ubuntu', 9))
|
||||
|
||||
''' Endpoint Label '''
|
||||
self.endpoint = ttk.Label(self.lb_frame2, textvariable=self.enp, foreground='#0071ff')
|
||||
self.endpoint.grid(column=0, row=8, sticky='w', padx=10, pady=20)
|
||||
self.endpoint.config(font=('Ubuntu', 9))
|
||||
|
||||
|
||||
class ListTunnels:
|
||||
"""
|
||||
Shows all existing Wireguard tunnels
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def tl_list():
|
||||
wg_s = os.popen('nmcli con show | grep -iPo "(.*)(wireguard)"').read().split()
|
||||
|
||||
''' tl = Tunnel list # Show of 4.Element in list '''
|
||||
tl = wg_s[::3]
|
||||
return tl
|
||||
|
||||
|
||||
class FileHandle:
|
||||
"""
|
||||
This class will display the autostart label which
|
||||
Tunnel is automatically started regardless of the active tunnel.
|
||||
The selected tunnel is written into a file to read it after the start of the system.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.wg_autostart = None
|
||||
self.autoconnect = None
|
||||
self.auto_con = None
|
||||
self.autoconnect_var = None
|
||||
self.tl = None
|
||||
self.selected_option = None
|
||||
self.l_box = None
|
||||
|
||||
def box_set(self):
|
||||
|
||||
try:
|
||||
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)
|
||||
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)
|
||||
|
||||
except IndexError:
|
||||
self.selected_option.set(1)
|
||||
|
||||
OnOff.on_off(self)
|
||||
|
||||
|
||||
class OnOff:
|
||||
"""
|
||||
Here it is checked whether the path to the file is there if not it is created.
|
||||
Set (on), the selected tunnel is displayed in the label.
|
||||
At (off) the label is first emptied then filled with No Autoconnect
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.wg_autostart = None
|
||||
self.selected_option = None
|
||||
self.auto_con = None
|
||||
self.autoconnect = None
|
||||
self.autoconnect_var = None
|
||||
self.lb_frame_buttons = None
|
||||
|
||||
def on_off(self):
|
||||
|
||||
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')
|
||||
self.auto_con = 'no Autoconnect'
|
||||
self.autoconnect_var.set('')
|
||||
self.autoconnect_var = tk.StringVar()
|
||||
self.autoconnect_var.set(self.auto_con)
|
||||
|
||||
self.autoconnect = ttk.Label(self, textvariable=self.autoconnect_var, foreground='#0071ff')
|
||||
self.autoconnect.config(font=('Ubuntu', 11))
|
||||
self.autoconnect.grid(column=0, row=4, sticky='ne', pady=19)
|
||||
|
||||
|
||||
class ExportTunnels:
|
||||
"""
|
||||
This will export the tunnels.
|
||||
A zipfile with current date and time is created
|
||||
in the user's home directory with correct right
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def wg_export():
|
||||
_u1 = str(_u[6:])
|
||||
now_time = datetime.now()
|
||||
now_datetime = now_time.strftime('wg-exp-' + '%m-%d-%Y' + '-' + '%H:%M')
|
||||
tl = ListTunnels.tl_list()
|
||||
|
||||
try:
|
||||
if len(tl) != 0:
|
||||
wg_tar = str(_u) + '/' + now_datetime
|
||||
shutil.copytree('/etc/wire_py', '/tmp/wire_py', dirs_exist_ok=True)
|
||||
source = Path('/tmp/wire_py')
|
||||
Path.unlink(Path(source) / 'wg_py', missing_ok=True)
|
||||
Path.unlink(Path(source) / '.keys', missing_ok=True)
|
||||
Path.unlink(Path(source) / 'settings', missing_ok=True)
|
||||
Path.unlink(Path(source) / 'theme', missing_ok=True)
|
||||
shutil.make_archive(wg_tar, 'zip', source)
|
||||
shutil.chown(wg_tar + '.zip', 1000, 1000)
|
||||
shutil.rmtree(source)
|
||||
with zipfile.ZipFile((wg_tar + '.zip'), 'r') as zf:
|
||||
if len(zf.namelist()) != 0:
|
||||
|
||||
"""img_w, img_i, w_title, w_txt hand over"""
|
||||
iw = r'/usr/share/icons/wp-icons/64/info.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_vpn.png'
|
||||
wt = 'Export Successful'
|
||||
msg_t = 'Your zip file is in home directory'
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
else:
|
||||
|
||||
"""img_w, img_i, w_title, w_txt hand over"""
|
||||
iw = r'/usr/share/icons/wp-icons/64/error.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Export error'
|
||||
msg_t = 'Export failed! Please try again'
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
else:
|
||||
|
||||
"""img_w, img_i, w_title, w_txt hand over"""
|
||||
iw = r'/usr/share/icons/wp-icons/64/info.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Select tunnel'
|
||||
msg_t = 'Please first import tunnel.'
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
|
||||
|