replace tar with zip and Check if Zip file is empty

This commit is contained in:
Désiré Werner Menrath 2024-09-20 14:55:15 +02:00
parent 3965844b6b
commit 41391b0ef1
2 changed files with 22 additions and 14 deletions

View File

@ -4,11 +4,9 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="install rollback bash to py wirepy rollback to py">
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="fix install and .desktop File Tar works now for user home and filebrowser.askfilebrowser start now in user home">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Wire-Py.desktop" beforeDir="false" afterPath="$PROJECT_DIR$/Wire-Py.desktop" afterDir="false" />
<change beforePath="$PROJECT_DIR$/wg_func.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_func.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/wirepy.py" beforeDir="false" afterPath="$PROJECT_DIR$/wirepy.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -447,7 +445,15 @@
<option name="project" value="LOCAL" />
<updated>1726770649542</updated>
</task>
<option name="localTasksCounter" value="40" />
<task id="LOCAL-00040" summary="fix install and .desktop File Tar works now for user home and filebrowser.askfilebrowser start now in user home">
<option name="closed" value="true" />
<created>1726777434040</created>
<option name="number" value="00040" />
<option name="presentableId" value="LOCAL-00040" />
<option name="project" value="LOCAL" />
<updated>1726777434040</updated>
</task>
<option name="localTasksCounter" value="41" />
<servers />
</component>
<component name="UnknownFeatures">
@ -488,7 +494,6 @@
</component>
<component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="add method init_and_report and label_empty to Class ShowAddress" />
<MESSAGE value="little fixes in Class Import" />
<MESSAGE value="fix label when laat Tunnel delete and fix Tuple error in delete and Start/Stop when listbox empty" />
<MESSAGE value="remove a ',' in DNS Name" />
@ -513,6 +518,7 @@
<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&#10;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" />
<option name="LAST_COMMIT_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" />
<option name="LAST_COMMIT_MESSAGE" value="fix install and .desktop File Tar works now for user home and filebrowser.askfilebrowser start now in user home" />
</component>
</project>

View File

@ -1,8 +1,9 @@
# Wireguard functions for Wire-Py
import os
import shutil
import zipfile
from datetime import datetime
from tkinter import filedialog
from tkinter import filedialog, messagebox
import tkinter as tk
from pathlib import Path
from subprocess import check_call
@ -11,6 +12,7 @@ font_color = '#4011a7'
path_to_file = Path('/etc/wire_py/wg_py')
_u = Path.read_text(Path('/tmp/_u'))
def msg_window():
msg = tk.Toplevel()
msg.resizable(width=False, height=False)
@ -182,7 +184,7 @@ class ImportTunnel:
def wg_import_select(self):
try:
filepath = filedialog.askopenfilename(initialdir=str(_u), title='Select Wireguard config File',
filetypes=[('WG config files', '*.conf')],)
filetypes=[('WG config files', '*.conf')], )
with open(filepath, 'r') as file:
read = file.read()
@ -302,11 +304,11 @@ class ExportTunnels:
wg_tar = str(_u) + '/' + now_datetime
p_to_conf = Path('/etc/wire_py/')
shutil.make_archive(wg_tar, 'zip', p_to_conf)
#if zip_full != 0:
#print('Export erfolgraeich')
#else:
#print('ups etwwas ging schief bitte Export wiederholen')
else:
print('No Tunnel for Export')
with zipfile.ZipFile((wg_tar + '.zip'), 'r') as zf:
if len(zf.namelist()) != 0:
messagebox.showinfo('Wire_py Export', 'Tarfile is in your Homedirectory')
else:
messagebox.showerror('Wire_py Export', 'Tarfile is failed please resume Export')
except TypeError:
pass