1.11.1024 #24
@ -1,4 +1,4 @@
|
||||
""" Wireguard Classes and Method for Wire-Py """
|
||||
""" Classes Method and functions for lx apps """
|
||||
|
||||
import gettext
|
||||
import locale
|
||||
@ -18,16 +18,22 @@ locale.bindtextdomain(APP, LOCALE_DIR)
|
||||
gettext.bindtextdomain(APP, LOCALE_DIR)
|
||||
gettext.textdomain(APP)
|
||||
_ = gettext.gettext
|
||||
''' 1 = 1. Year, 09 = Month of the Year, 2924 = Day and Year of the Year '''
|
||||
version = 'v. 1.11.0924'
|
||||
|
||||
path_to_file2 = Path('/etc/wire_py/settings.conf')
|
||||
_u = Path.read_text(Path('/tmp/_u'))
|
||||
|
||||
|
||||
class GiteaUpdate:
|
||||
"""
|
||||
Calling api_down requests the URL and version from the running script.
|
||||
Example: version = 'v. 1.1.1.1' GiteaUpdate.api_down(http://example.de, version)
|
||||
|
||||
The call to download requests the download URL from 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):
|
||||
def api_down(update_api_url, version):
|
||||
try:
|
||||
response = requests.get(update_api_url)
|
||||
response_dict = response.json()
|
||||
@ -45,7 +51,7 @@ class GiteaUpdate:
|
||||
return 'No Internet Connection!'
|
||||
|
||||
@staticmethod
|
||||
def download(urld):
|
||||
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)
|
||||
@ -53,7 +59,7 @@ class GiteaUpdate:
|
||||
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 = r'/usr/share/icons/wp-icons/48/wg_vpn.png'
|
||||
ii = down_ok_image
|
||||
wt = _('Download Successful')
|
||||
msg_t = _('Your zip file is in home directory')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
@ -61,22 +67,19 @@ class GiteaUpdate:
|
||||
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'
|
||||
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 = r'/usr/share/icons/wg-icons/48/wg_msg.png'
|
||||
ii = down_not_ok_image
|
||||
wt = _('Download error')
|
||||
msg_t = _('Download failed! No internet connection!')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
|
||||
res = GiteaUpdate.api_down('https://git.ilunix.de/api/v1/repos/punix/Wire-Py/releases')
|
||||
|
||||
|
||||
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.
|
||||
@ -86,6 +89,8 @@ def msg_window(img_w, img_i, w_title, w_txt, txt2=None, com=None):
|
||||
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()
|
||||
|
23
wg_main.py
23
wg_main.py
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import gettext
|
||||
import locale
|
||||
import os
|
||||
@ -8,12 +9,17 @@ import tkinter as tk
|
||||
from pathlib import Path
|
||||
from subprocess import check_call
|
||||
from tkinter import filedialog, ttk, TclError
|
||||
|
||||
from cls_mth_fc import (Tunnel, msg_window, GiteaUpdate, res, _u, version, path_to_file2, tips)
|
||||
from cls_mth_fc import (Tunnel, msg_window, GiteaUpdate, _u, path_to_file2, tips)
|
||||
|
||||
tcl_path = Path('/usr/share/TK-Themes')
|
||||
|
||||
APP = 'wg_main'
|
||||
''' 1 = 1. Year, 09 = Month of the Year, 2924 = Day and Year of the Year '''
|
||||
version = 'v. 1.11.0924'
|
||||
|
||||
res = GiteaUpdate.api_down('https://git.ilunix.de/api/v1/repos/punix/Wire-Py/releases', version)
|
||||
|
||||
''' Translate '''
|
||||
APP = 'wirepy'
|
||||
LOCALE_DIR = "/usr/share/locale/"
|
||||
locale.bindtextdomain(APP, LOCALE_DIR)
|
||||
gettext.bindtextdomain(APP, LOCALE_DIR)
|
||||
@ -266,8 +272,15 @@ class FrameWidgets(ttk.Frame):
|
||||
self.download = tk.Menu(self, relief='flat')
|
||||
|
||||
self.update_btn.configure(menu=self.download, style='Toolbutton')
|
||||
self.download.add_command(label=_('Download'), command=GiteaUpdate.download(f'https://git.ilunix.de/punix'
|
||||
f'/Wire-Py/archive/{res}.zip'))
|
||||
self.download.add_command(label=_('Download'),
|
||||
command=lambda: GiteaUpdate.download(f'https://git.ilunix.de/punix'
|
||||
f'/Wire-Py/archive/'
|
||||
f'{res}.zip', r'/usr/'
|
||||
r'share/icons/wp-icons'
|
||||
r'/48/wg_vpn.png',
|
||||
r'/usr/share/icons/wp-icons'
|
||||
r'/48/wg_msg.png', res))
|
||||
|
||||
''' Show active Tunnel '''
|
||||
self.a = Tunnel.active()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user