from PyQt5.QtCore import QThread, pyqtSignal from PyQt5.QtGui import QColor import time from sync import FolderSynchronizer class JobThread(QThread): current_log = pyqtSignal(str, QColor, QColor) def __init__(self, job_item): super().__init__() self.name = job_item.name self.folder1 = job_item.folder1 self.folder2 = job_item.folder2 self.interval = job_item.interval self.is_running = False self.synchronizer = FolderSynchronizer(self.name, self.folder1, self.folder2, self.interval) def run(self): self.is_running = True while self.is_running: log = self.synchronizer.sync_folders() self.current_log.emit(log, QColor("white"), QColor("green")) time.sleep(self.interval) def stop(self): self.is_running = False def sync(self): log = self.synchronizer.sync_folders() self.current_log.emit(log, QColor("yellow"), QColor("green"))