This commit is contained in:
Stefan Ritter 2023-10-18 23:58:09 +02:00
parent dc1d46c8ca
commit 5ab2c2f97d
2 changed files with 38 additions and 29 deletions

View File

@ -1,7 +1,7 @@
from PyQt6.QtWidgets import QApplication from PyQt6.QtWidgets import QApplication
from wmain import wMain from wmain import wMain
version = "20231018" version = "20231019"
if __name__ == "__main__": if __name__ == "__main__":
app = QApplication([]) app = QApplication([])

View File

@ -12,7 +12,6 @@ from PyQt6.QtWidgets import QLabel
from PyQt6.QtWidgets import QPushButton from PyQt6.QtWidgets import QPushButton
from PyQt6.QtWidgets import QStyle from PyQt6.QtWidgets import QStyle
from PyQt6.QtWidgets import QProgressBar from PyQt6.QtWidgets import QProgressBar
from PyQt6.QtCore import QThread
class wArchive(QDialog): class wArchive(QDialog):
@ -187,46 +186,56 @@ class wArchive(QDialog):
self.bArchive.setEnabled(True) self.bArchive.setEnabled(True)
def copyDataThread(self): def copyDataThread(self):
self.copyDataThread = threading.Thread(target=self.copyData) threads = []
self.copyDataThread = threading.Thread(target=copyData, args=(self,
self.bArchive,
self.progressBar,
self.files,
self.ArchivePath,
self.pName,
self.pBirth,))
threads.append(self.copyDataThread)
self.copyDataThread.start() self.copyDataThread.start()
self.copyDataThread.join()
# Close wArchive class copyData():
self.close() def __init__(self, warchive, barchive, progressbar, files, archivepath, pname, pbirth):
self.warchive = warchive
self.barchive = barchive
self.progressbar = progressbar
self.files = files
self.archivepath = archivepath
self.pname = pname
self.pbirth = pbirth
def copyData(self): self.barchive.setEnabled(False)
self.bArchive.setEnabled(False) mainFolder = os.path.join(self.archivepath, self.pname + "^" + self.pbirth)
source = self.files
# LastName^FirstName^Birth
mainFolder = os.path.join(self.ArchivePath, self.pName + "^" + self.pBirth)
try: try:
os.mkdir(mainFolder) os.mkdir(mainFolder)
except: except:
pass pass
# LastName^FirstName^Birth\1234 subFolder = randomString(4)
subFolder = self.randomString(4)
os.mkdir(os.path.join(mainFolder, subFolder)) os.mkdir(os.path.join(mainFolder, subFolder))
filename = 1 filename = 1
for file in source: for file in self.files:
shutil.copy(file, os.path.join(mainFolder, subFolder, str(filename))) shutil.copy(file, os.path.join(mainFolder, subFolder, str(filename)))
self.progressBar.setValue(int(filename / len(self.files) * 100)) self.progressbar.setValue(int(filename / len(self.files) * 100))
filename += 1 filename += 1
# Eject CD
ctypes.windll.WINMM.mciSendStringW(u"set cdaudio door open", None, 0, None) ctypes.windll.WINMM.mciSendStringW(u"set cdaudio door open", None, 0, None)
@staticmethod self.barchive.setEnabled(True)
def randomString(length): self.warchive.hide()
string = ""
chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
for _ in range(length): @staticmethod
char = random.choice(chars) def randomString(length):
string = string + char string = ""
chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
return string for _ in range(length):
char = random.choice(chars)
string = string + char
return string