fix when Filname > 17 first copy file after rename

This commit is contained in:
2024-08-25 15:39:23 +02:00
parent 8d657f7c09
commit 980c5a9010
3 changed files with 18 additions and 8 deletions

View File

@ -1,6 +1,6 @@
# Wireguard functions for Wire-Py
import os
import subprocess
import shutil
from tkinter import filedialog
import tkinter as tk
@ -182,14 +182,15 @@ class ImportTunnel:
pathsplit1 = pathsplit[-1]
if "PrivateKey = " in read and "PublicKey = " in read:
if len(pathsplit1) > 17:
p1 = shutil.copy(filepath, os.environ['HOME'] + '/tester/')
pathsplit = pathsplit1[len(pathsplit1) - 17:]
os.rename(filepath, os.environ['HOME'] + '/tester/' + str(pathsplit))
os.rename(p1, os.environ['HOME'] + '/tester/' + str(pathsplit))
if self.a != '':
os.system('nmcli connection down ' + str(TunnelActiv.active()))
os.system('nmcli connection import type wireguard file ' + os.environ['HOME'] + '/tester/' +
str(pathsplit))
else:
subprocess.call('cp ' + str(filepath) + ' ' + os.environ['HOME'] + '/tester/', shell=True)
shutil.copy(filepath, os.environ['HOME'] + '/tester/')
if self.a != '':
os.system('nmcli connection down ' + str(TunnelActiv.active()))
os.system('nmcli connection import type wireguard file ' + str(filepath))