04-06-2025_large_update #35
										
											Binary file not shown.
										
									
								
							@@ -4,14 +4,15 @@ import gettext
 | 
			
		||||
import locale
 | 
			
		||||
import os
 | 
			
		||||
import shutil
 | 
			
		||||
import signal
 | 
			
		||||
import subprocess
 | 
			
		||||
import sys
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
APP = "wirepy"
 | 
			
		||||
@@ -378,6 +379,43 @@ class Tunnel:
 | 
			
		||||
            pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def sigi(dirname):
 | 
			
		||||
    """
 | 
			
		||||
    function for clean up after break
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    def signal_handler(signum, frame):
 | 
			
		||||
        """
 | 
			
		||||
        Determine clear text names for signal numbers
 | 
			
		||||
        """
 | 
			
		||||
        signals_to_names_dict = dict(
 | 
			
		||||
            (getattr(signal, n), n)
 | 
			
		||||
            for n in dir(signal)
 | 
			
		||||
            if n.startswith("SIG") and "_" not in n
 | 
			
		||||
        )
 | 
			
		||||
        signame = signals_to_names_dict.get(signum, f"Unnamed signal: {signum}")
 | 
			
		||||
 | 
			
		||||
        # End program for certain signals, report to others only reception
 | 
			
		||||
        if signum in (signal.SIGINT, signal.SIGTERM):
 | 
			
		||||
            exit_code = 1
 | 
			
		||||
            print(
 | 
			
		||||
                f"\nSignal {signame} {(signum)} received. => Aborting with exit code {exit_code}."
 | 
			
		||||
            )
 | 
			
		||||
            shutil.rmtree(dirname)
 | 
			
		||||
            Path.unlink("/tmp/.loguser")
 | 
			
		||||
            print("Breakdown by user...")
 | 
			
		||||
            sys.exit(exit_code)
 | 
			
		||||
        else:
 | 
			
		||||
            print(f"Signal {signum} received and ignored.")
 | 
			
		||||
            shutil.rmtree(dirname)
 | 
			
		||||
            Path.unlink("/tmp/.loguser")
 | 
			
		||||
            print("Process unexpectedly ended...")
 | 
			
		||||
 | 
			
		||||
    signal.signal(signal.SIGINT, signal_handler)
 | 
			
		||||
    signal.signal(signal.SIGTERM, signal_handler)
 | 
			
		||||
    signal.signal(signal.SIGHUP, signal_handler)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def if_tip(path):
 | 
			
		||||
    """
 | 
			
		||||
    method that writes in file whether tooltip is displayed or not
 | 
			
		||||
@@ -402,21 +440,24 @@ class Tooltip:
 | 
			
		||||
    info: label and button is parrent.
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    def __init__(self, widget, text, TIPS=None):
 | 
			
		||||
    def __init__(self, widget, text, tips=None):
 | 
			
		||||
        self.widget = widget
 | 
			
		||||
        self.text = text
 | 
			
		||||
        self.tooltip_window = None
 | 
			
		||||
        if TIPS:
 | 
			
		||||
        if tips:
 | 
			
		||||
            self.widget.bind("<Enter>", self.show_tooltip)
 | 
			
		||||
            self.widget.bind("<Leave>", self.hide_tooltip)
 | 
			
		||||
 | 
			
		||||
    def show_tooltip(self, event=None):
 | 
			
		||||
        """
 | 
			
		||||
        shows the tooltip
 | 
			
		||||
        """
 | 
			
		||||
        if self.tooltip_window or not self.text:
 | 
			
		||||
            return
 | 
			
		||||
 | 
			
		||||
        x, y, _, _ = self.widget.bbox("insert")
 | 
			
		||||
        x += self.widget.winfo_rootx() + 25
 | 
			
		||||
        y += self.widget.winfo_rooty() + 20
 | 
			
		||||
        x += self.widget.winfo_rootx() + 40
 | 
			
		||||
        y += self.widget.winfo_rooty() + 40
 | 
			
		||||
        self.tooltip_window = tw = tk.Toplevel(self.widget)
 | 
			
		||||
        tw.wm_overrideredirect(True)
 | 
			
		||||
        tw.wm_geometry(f"+{x}+{y}")
 | 
			
		||||
@@ -427,6 +468,9 @@ class Tooltip:
 | 
			
		||||
        label.grid()
 | 
			
		||||
 | 
			
		||||
    def hide_tooltip(self, event=None):
 | 
			
		||||
        """
 | 
			
		||||
        hide the tooltip
 | 
			
		||||
        """
 | 
			
		||||
        if self.tooltip_window:
 | 
			
		||||
            self.tooltip_window.destroy()
 | 
			
		||||
            self.tooltip_window = None
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										110
									
								
								wirepy.py
									
									
									
									
									
								
							
							
						
						
									
										110
									
								
								wirepy.py
									
									
									
									
									
								
							@@ -7,14 +7,22 @@ import locale
 | 
			
		||||
import webbrowser
 | 
			
		||||
import os
 | 
			
		||||
import sys
 | 
			
		||||
import signal
 | 
			
		||||
import subprocess
 | 
			
		||||
import shutil
 | 
			
		||||
import tkinter as tk
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
from subprocess import check_call
 | 
			
		||||
from tkinter import filedialog, ttk, TclError
 | 
			
		||||
from cls_mth_fc import Tooltip, Tunnel, Create, msg_window, if_tip, GiteaUpdate, uos
 | 
			
		||||
from cls_mth_fc import (
 | 
			
		||||
    Tooltip,
 | 
			
		||||
    Tunnel,
 | 
			
		||||
    Create,
 | 
			
		||||
    msg_window,
 | 
			
		||||
    sigi,
 | 
			
		||||
    if_tip,
 | 
			
		||||
    GiteaUpdate,
 | 
			
		||||
    uos,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
uos()
 | 
			
		||||
Create.dir_and_files()
 | 
			
		||||
@@ -23,7 +31,7 @@ Create.decrypt()
 | 
			
		||||
 | 
			
		||||
tcl_path = Path("/usr/share/TK-Themes")
 | 
			
		||||
wg_set = Path(Path.home() / ".config/wire_py/settings")
 | 
			
		||||
TIPS = if_tip(wg_set)
 | 
			
		||||
tips = if_tip(wg_set)
 | 
			
		||||
dirname = Path("/tmp/tlecdcwg/")
 | 
			
		||||
 | 
			
		||||
# 1 = 1. Year, 09 = Month of the Year, 2924 = Day and Year of the Year
 | 
			
		||||
@@ -41,38 +49,7 @@ gettext.bindtextdomain(APP, LOCALE_DIR)
 | 
			
		||||
gettext.textdomain(APP)
 | 
			
		||||
_ = gettext.gettext
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def signal_handler(signum, frame):
 | 
			
		||||
    """
 | 
			
		||||
    Determine clear text names for signal numbers
 | 
			
		||||
    """
 | 
			
		||||
    signals_to_names_dict = dict(
 | 
			
		||||
        (getattr(signal, n), n)
 | 
			
		||||
        for n in dir(signal)
 | 
			
		||||
        if n.startswith("SIG") and "_" not in n
 | 
			
		||||
    )
 | 
			
		||||
    signame = signals_to_names_dict.get(signum, f"Unnamed signal: {signum}")
 | 
			
		||||
 | 
			
		||||
    # End program for certain signals, report to others only reception
 | 
			
		||||
    if signum in (signal.SIGINT, signal.SIGTERM):
 | 
			
		||||
        exit_code = 1
 | 
			
		||||
        print(
 | 
			
		||||
            f"\nSignal {signame} {(signum)} received. => Aborting with exit code {exit_code}."
 | 
			
		||||
        )
 | 
			
		||||
        shutil.rmtree(dirname)
 | 
			
		||||
        Path.unlink("/tmp/.loguser")
 | 
			
		||||
        print("Breakdown by user...")
 | 
			
		||||
        sys.exit(exit_code)
 | 
			
		||||
    else:
 | 
			
		||||
        print(f"Signal {signum} received and ignored.")
 | 
			
		||||
        shutil.rmtree(dirname)
 | 
			
		||||
        Path.unlink("/tmp/.loguser")
 | 
			
		||||
        print("Process unexpectedly ended...")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
signal.signal(signal.SIGINT, signal_handler)
 | 
			
		||||
signal.signal(signal.SIGTERM, signal_handler)
 | 
			
		||||
signal.signal(signal.SIGHUP, signal_handler)
 | 
			
		||||
sigi(dirname)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Wirepy(tk.Tk):
 | 
			
		||||
@@ -238,12 +215,12 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
        self.version_lb.config(font=("Ubuntu", 11), foreground="#00c4ff")
 | 
			
		||||
        self.version_lb.grid(column=0, row=0, rowspan=4, padx=10)
 | 
			
		||||
 | 
			
		||||
        Tooltip(self.version_lb, f"Version: {VERSION[2:]}", TIPS)
 | 
			
		||||
        Tooltip(self.version_lb, f"Version: {VERSION[2:]}", tips)
 | 
			
		||||
 | 
			
		||||
        self.options_btn = ttk.Menubutton(self.menu_frame, text=_("Options"))
 | 
			
		||||
        self.options_btn.grid(column=1, columnspan=1, row=0)
 | 
			
		||||
 | 
			
		||||
        Tooltip(self.options_btn, _("Click for Settings"), TIPS)
 | 
			
		||||
        Tooltip(self.options_btn, _("Click for Settings"), tips)
 | 
			
		||||
 | 
			
		||||
        set_update = tk.IntVar()
 | 
			
		||||
        set_tip = tk.BooleanVar()
 | 
			
		||||
@@ -270,7 +247,7 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
        self.updates_lb.grid(column=4, columnspan=3, row=0, padx=10)
 | 
			
		||||
 | 
			
		||||
        # View Checkbox for enable or disable Tooltip
 | 
			
		||||
        if TIPS:
 | 
			
		||||
        if tips:
 | 
			
		||||
            set_tip.set(value=False)
 | 
			
		||||
        else:
 | 
			
		||||
            set_tip.set(value=True)
 | 
			
		||||
@@ -280,14 +257,14 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
            set_update.set(value=1)
 | 
			
		||||
            self.updates_lb.configure(text=_("Update search off"))
 | 
			
		||||
 | 
			
		||||
            Tooltip(self.updates_lb, _("Updates you have disabled"), TIPS)
 | 
			
		||||
            Tooltip(self.updates_lb, _("Updates you have disabled"), tips)
 | 
			
		||||
 | 
			
		||||
        elif res == "No Internet Connection!":
 | 
			
		||||
            self.updates_lb.configure(text=_("No Server Connection!"), foreground="red")
 | 
			
		||||
        elif res == "No Updates":
 | 
			
		||||
            self.updates_lb.configure(text=_("No Updates"))
 | 
			
		||||
 | 
			
		||||
            Tooltip(self.updates_lb, _("Congratulations! Wire-Py is up to date"), TIPS)
 | 
			
		||||
            Tooltip(self.updates_lb, _("Congratulations! Wire-Py is up to date"), tips)
 | 
			
		||||
 | 
			
		||||
        else:
 | 
			
		||||
            set_update.set(value=0)
 | 
			
		||||
@@ -297,7 +274,7 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
            self.update_btn = ttk.Menubutton(self.menu_frame, text=text)
 | 
			
		||||
            self.update_btn.grid(column=4, columnspan=3, row=0, padx=0)
 | 
			
		||||
 | 
			
		||||
            Tooltip(self.update_btn, _("Click to download new version"), TIPS)
 | 
			
		||||
            Tooltip(self.update_btn, _("Click to download new version"), tips)
 | 
			
		||||
 | 
			
		||||
            self.download = tk.Menu(self, relief="flat")
 | 
			
		||||
 | 
			
		||||
@@ -420,7 +397,7 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
        )
 | 
			
		||||
        self.btn_i.grid(column=0, row=1, padx=15, pady=8)
 | 
			
		||||
 | 
			
		||||
        Tooltip(self.btn_i, _("Click to import a Wireguard Tunnel"), TIPS)
 | 
			
		||||
        Tooltip(self.btn_i, _("Click to import a Wireguard Tunnel"), tips)
 | 
			
		||||
 | 
			
		||||
        def delete():
 | 
			
		||||
            """
 | 
			
		||||
@@ -473,23 +450,20 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
                if self.l_box.size() == 0:
 | 
			
		||||
                    self.wg_autostart.configure(state="disabled")
 | 
			
		||||
                    self.lb_rename.configure(state="disabled")
 | 
			
		||||
                    Tooltip(
 | 
			
		||||
                        self.l_box, _("You must first import\na Wireguard tunnel"), TIPS
 | 
			
		||||
                    )
 | 
			
		||||
                    Tooltip(
 | 
			
		||||
                        self.wg_autostart,
 | 
			
		||||
                        _(
 | 
			
		||||
                            "You must have at least one\ntunnel in the list,to use the autostart"
 | 
			
		||||
                        ),
 | 
			
		||||
                        TIPS,
 | 
			
		||||
                        tips,
 | 
			
		||||
                    )
 | 
			
		||||
 | 
			
		||||
                    Tooltip(self.btn_exp, _("No Tunnels in List for Export"), TIPS)
 | 
			
		||||
                    Tooltip(self.btn_stst, _("No tunnels to start in the list"), TIPS)
 | 
			
		||||
                    Tooltip(self.btn_exp, _("No Tunnels in List for Export"), tips)
 | 
			
		||||
                    Tooltip(self.btn_stst, _("No tunnels to start in the list"), tips)
 | 
			
		||||
                    Tooltip(
 | 
			
		||||
                        self.lb_rename,
 | 
			
		||||
                        _("To rename a tunnel, at least one must be in the list"),
 | 
			
		||||
                        TIPS,
 | 
			
		||||
                        tips,
 | 
			
		||||
                    )
 | 
			
		||||
                    self.lb_rename.insert(0, _("Max. 12 characters!"))
 | 
			
		||||
 | 
			
		||||
@@ -535,12 +509,12 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
        self.btn_tr.grid(column=0, row=2, padx=15, pady=8)
 | 
			
		||||
 | 
			
		||||
        if self.l_box.size() == 0:
 | 
			
		||||
            Tooltip(self.btn_tr, _("No tunnels to delete in the list"), TIPS)
 | 
			
		||||
            Tooltip(self.btn_tr, _("No tunnels to delete in the list"), tips)
 | 
			
		||||
        else:
 | 
			
		||||
            Tooltip(
 | 
			
		||||
                self.btn_tr,
 | 
			
		||||
                _("Click to delete a Wireguard Tunnel\nSelect from the list!"),
 | 
			
		||||
                TIPS,
 | 
			
		||||
                tips,
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        # Button Export
 | 
			
		||||
@@ -550,12 +524,12 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
        self.btn_exp.grid(column=0, row=3, padx=15, pady=8)
 | 
			
		||||
 | 
			
		||||
        if self.l_box.size() == 0:
 | 
			
		||||
            Tooltip(self.btn_exp, _("No Tunnels in List for Export"), TIPS)
 | 
			
		||||
            Tooltip(self.btn_exp, _("No Tunnels in List for Export"), tips)
 | 
			
		||||
        else:
 | 
			
		||||
            Tooltip(
 | 
			
		||||
                self.btn_exp,
 | 
			
		||||
                _("         Click to export all\nWireguard Tunnel to Zipfile"),
 | 
			
		||||
                TIPS,
 | 
			
		||||
                tips,
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        # Label Entry
 | 
			
		||||
@@ -568,13 +542,13 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
            Tooltip(
 | 
			
		||||
                self.lb_rename,
 | 
			
		||||
                _("To rename a tunnel, you need to\nselect a tunnel from the list"),
 | 
			
		||||
                TIPS,
 | 
			
		||||
                tips,
 | 
			
		||||
            )
 | 
			
		||||
        else:
 | 
			
		||||
            Tooltip(
 | 
			
		||||
                self.lb_rename,
 | 
			
		||||
                _("To rename a tunnel, at least one must be in the list"),
 | 
			
		||||
                TIPS,
 | 
			
		||||
                tips,
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        def tl_rename():
 | 
			
		||||
@@ -698,7 +672,7 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
        if self.l_box.size() >= 1 and len(self.l_box.curselection()) >= 1:
 | 
			
		||||
 | 
			
		||||
            Tooltip(
 | 
			
		||||
                self.wg_autostart, _("To use the autostart, enable this Checkbox"), TIPS
 | 
			
		||||
                self.wg_autostart, _("To use the autostart, enable this Checkbox"), tips
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        if self.l_box.size() == 0:
 | 
			
		||||
@@ -707,7 +681,7 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
                _(
 | 
			
		||||
                    "You must have at least one\ntunnel in the list,to use the autostart"
 | 
			
		||||
                ),
 | 
			
		||||
                TIPS,
 | 
			
		||||
                tips,
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        else:
 | 
			
		||||
@@ -715,7 +689,7 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
            Tooltip(
 | 
			
		||||
                self.wg_autostart,
 | 
			
		||||
                _("To use the autostart, a tunnel must be selected from the list"),
 | 
			
		||||
                TIPS,
 | 
			
		||||
                tips,
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        self.on_off()
 | 
			
		||||
@@ -858,7 +832,7 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
                                    Tooltip(
 | 
			
		||||
                                        self.wg_autostart,
 | 
			
		||||
                                        _("To use the autostart, enable this Checkbox"),
 | 
			
		||||
                                        TIPS,
 | 
			
		||||
                                        tips,
 | 
			
		||||
                                    )
 | 
			
		||||
 | 
			
		||||
                                    # Tooltip(self.l_box, _("List of available tunnels"))
 | 
			
		||||
@@ -869,7 +843,7 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
                                            "Click to delete a Wireguard Tunnel\n"
 | 
			
		||||
                                            "Select from the list!"
 | 
			
		||||
                                        ),
 | 
			
		||||
                                        TIPS,
 | 
			
		||||
                                        tips,
 | 
			
		||||
                                    )
 | 
			
		||||
 | 
			
		||||
                                    Tooltip(
 | 
			
		||||
@@ -878,7 +852,7 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
                                            "         Click to export all\n"
 | 
			
		||||
                                            "Wireguard Tunnel to Zipfile"
 | 
			
		||||
                                        ),
 | 
			
		||||
                                        TIPS,
 | 
			
		||||
                                        tips,
 | 
			
		||||
                                    )
 | 
			
		||||
 | 
			
		||||
                                    Tooltip(
 | 
			
		||||
@@ -887,7 +861,7 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
                                            "To rename a tunnel, you need to\n"
 | 
			
		||||
                                            "select a tunnel from the list"
 | 
			
		||||
                                        ),
 | 
			
		||||
                                        TIPS,
 | 
			
		||||
                                        tips,
 | 
			
		||||
                                    )
 | 
			
		||||
 | 
			
		||||
                                    self.lb_rename.insert(0, "Max. 12 characters!")
 | 
			
		||||
@@ -932,11 +906,10 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
        except EOFError as e:
 | 
			
		||||
            print(e)
 | 
			
		||||
        except TypeError as e:
 | 
			
		||||
            print(e)
 | 
			
		||||
            print("File import: abort by user...")
 | 
			
		||||
        except FileNotFoundError as e:
 | 
			
		||||
            print(e)
 | 
			
		||||
            print("File import: abort by user...")
 | 
			
		||||
        except subprocess.CalledProcessError:
 | 
			
		||||
 | 
			
		||||
            print("Tunnel exist!")
 | 
			
		||||
 | 
			
		||||
    def box_set(self):
 | 
			
		||||
@@ -1063,7 +1036,7 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
        )
 | 
			
		||||
        self.btn_stst.grid(column=0, row=0, padx=5, pady=8)
 | 
			
		||||
 | 
			
		||||
        Tooltip(self.btn_stst, _("Click to stop selected Wireguard Tunnel"), TIPS)
 | 
			
		||||
        Tooltip(self.btn_stst, _("Click to stop selected Wireguard Tunnel"), tips)
 | 
			
		||||
 | 
			
		||||
    def start(self):
 | 
			
		||||
        """
 | 
			
		||||
@@ -1079,9 +1052,9 @@ class FrameWidgets(ttk.Frame):
 | 
			
		||||
 | 
			
		||||
        tl = Tunnel.list()
 | 
			
		||||
        if len(tl) == 0:
 | 
			
		||||
            Tooltip(self.btn_stst, _("No tunnels to start in the list"), TIPS)
 | 
			
		||||
            Tooltip(self.btn_stst, _("No tunnels to start in the list"), tips)
 | 
			
		||||
        else:
 | 
			
		||||
            Tooltip(self.btn_stst, _("Click to start selected Wireguard Tunnel"), TIPS)
 | 
			
		||||
            Tooltip(self.btn_stst, _("Click to start selected Wireguard Tunnel"), tips)
 | 
			
		||||
 | 
			
		||||
    def color_label(self):
 | 
			
		||||
        """
 | 
			
		||||
@@ -1178,7 +1151,6 @@ if __name__ == "__main__":
 | 
			
		||||
        window.tk.call("tk_getOpenFile", "-foobarbaz")
 | 
			
		||||
    except TclError:
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
    window.tk.call("set", "::tk::dialog::file::showHiddenBtn", "0")
 | 
			
		||||
    window.tk.call("set", "::tk::dialog::file::showHiddenVar", "0")
 | 
			
		||||
    window.mainloop()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user