def do_start(self): """ Perform startup operations and shows the dialog. Called once, on dialog startup.""" #Connect the signals from the View to the Slots self.dialogSlots = SourceDialogSlots(self.downloadModel,self.view) self.view.set_slots(self.dialogSlots) # Initialize the GUI self.view.set_GUI() # Load values from JSON if the user choosed the Remember Sources Option last time appPath = get_appData_path() try: file = open(os.path.join(appPath,"sources.json"),"r") data = json.load(file) file.close() for entry in data: self.view.add_source(entry["option"],entry["value"]) except FileNotFoundError: pass except json.decoder.JSONDecodeError: file.close() # Show the GUI self.view.show()
def __init__(self, downloadList, isLoop): super().__init__() self.downloadList = downloadList self.isLoop = isLoop self.isRunning = False self.appPath = get_appData_path() self.download = DownloadPgn()
def __init__(self, filePathList, isLoop, lock=None): super().__init__() self.filePathList = filePathList self.isLoop = isLoop self.isRunning = False self.lock = lock self.daemon = True appPath = get_appData_path() self.filename = os.path.join(appPath, "games.pgn")
def __init__(self,model,view): super().__init__() self.model = model self.view = view self.appPath = get_appData_path() self.threadPool = QThreadPool() self.filepathList = [] self.downloadList = [] self.validSources = []
def do_start(self): """ Perform startup operations and shows the dialog. Called once, on application startup. """ appPath = get_appData_path() # Set up application directory if not os.path.exists(appPath): os.makedirs(appPath) #Connect the signals from the View to the Slots self.slots = ChessClaimSlots(self.model,self.view) self.view.set_slots(self.slots) # Initialize the GUI self.view.set_GUI() # Show the GUI self.view.show()
def on_scanButton_clicked(self): """ Creates the necessary thread(workers) in order to scan the pgn(s) for the draw claims. trigger: User clicks the "Start Scan" Button on the Main Window. """ """ If the scan thread is alive it means the scan button is already clicked before. So if the user click it again nothing should happen.""" try: if (self.scanWorker.isRunning): return except: pass """ Check if there any valid sources before the start of the scan. If there aren't any valid sources raire the warning dialog and return.""" if (self.dialogFirstTime): self.view.load_warning() return filepathList = self.dialog.get_filepathList() if not filepathList: self.view.load_warning() return self.view.clear_table() # Clear the table of the output in the case of a previous scan. self.view.change_scanButton_text("active") """ If at least one of the sources is from the web we create a download therad(downloadWorker) to continuously download the web source(s). """ self.hasDownloadWorker = False downloadList = self.dialog.get_downloadList() if downloadList: self.downloadWorker = DownloadList(downloadList,True) self.downloadWorker.statusSignal.connect(self.update_statusBar_download) self.hasDownloadWorker = True self.downloadWorker.start() """ We create a thread(makePgnWorker) to continuously making the combined pgn from all the pgn's that were set as sources Also, a pyqt Signals is connected to this thread in order to update the downloadLabel in the statusBar. fileLock: Is a Lock Object. Both makePgnWorker thread and scanWorker thread (see below) access the combined games.pgn for writing and reading. Thus to avoid any conflict, with the use of fileLock, we make sure that only one thread per time uses the game.pgn. """ fileLock = Lock() self.makePgnWorker = MakePgn(filepathList,True,fileLock) self.makePgnWorker.start() appPath = get_appData_path() filename = os.path.join(appPath,"games.pgn") """ Create a thread(scanWorker) to scan the combined pgn using the Model. Also, two pyqt Signals are connected to this thread in order to update the claimsTable and the statusBar in the GUI. """ livePgnOption = self.view.livePgnOption self.scanWorker = Scan(self.model,filename,fileLock,livePgnOption) self.scanWorker.addEntrySignal.connect(self.update_claimsTable) self.scanWorker.statusSignal.connect(self.update_statusBar_scan) self.scanWorker.start()