コード例 #1
0
ファイル: search.py プロジェクト: ihumphrey/Xi-cam.gui
    def process_queries(self):
        # If there is a backlog, process only the newer query.
        block = True

        while True:
            try:
                query = self.query_queue.get_nowait()
                block = False
            except queue.Empty:
                if block:
                    query = self.query_queue.get()
                break
        log.debug('Submitting query %r', query)
        try:
            t0 = time.monotonic()
            msg.showMessage("Running Query")
            msg.showBusy()
            self._results_catalog = self.selected_catalog.search(query)
            found_new = self.check_for_new_entries()
            duration = time.monotonic() - t0
            log.debug('Query yielded %r results (%.3f s).',
                      len(self._results_catalog), duration)
            if found_new and self.show_results_event.is_set():
                self.new_results_catalog.emit()
        except Exception as e:
            msg.logError(e)
            msg.showMessage("Problem running query")
        finally:
            msg.hideBusy()
コード例 #2
0
ファイル: search.py プロジェクト: ihumphrey/Xi-cam.gui
    def show_results(self):
        header_labels_set = False
        self.show_results_event.clear()
        t0 = time.monotonic()
        counter = 0

        try:
            msg.showBusy()
            while not self._new_uids_queue.empty():
                counter += 1
                row = []
                new_uid = self._new_uids_queue.get()
                try:
                    entry = self.get_run_by_uid(new_uid)
                    row_data = self.apply_search_result_row(entry)
                except SkipRow as e:
                    msg.showMessage(str(msg))
                    msg.logError(e)
                    continue
                if not header_labels_set:
                    # Set header labels just once.
                    threads.invoke_in_main_thread(
                        self.search_results_model.setHorizontalHeaderLabels,
                        list(row_data))
                    header_labels_set = True
                for value in row_data.values():
                    item = QStandardItem()
                    item.setData(value, Qt.DisplayRole)
                    item.setData(new_uid, Qt.UserRole)
                    row.append(item)
                if QThread.currentThread().isInterruptionRequested():
                    self.show_results_event.set()
                    msg.logMessage("Interrupt requested")
                    return
                threads.invoke_in_main_thread(
                    self.search_results_model.appendRow, row)
            if counter:
                self.sig_update_header.emit()
                duration = time.monotonic() - t0
                msg.showMessage("Displayed {} new results {}.".format(
                    counter, duration))
            self.show_results_event.set()
        except Exception as e:
            msg.showMessage("Error displaying runs")
            msg.logError(e)
        finally:
            msg.hideBusy()