Esempio n. 1
0
    def initDataBaseManager(self, timeout=None):
        connected = False
        self.dbManager = MongoDBManager(self.mongodbHost, self.dbName)

        tStart = time.time()
        while not connected and (timeout == None
                                 or time.time() - tStart < timeout
                                 ) and not self.appInfo.applicationQuitting:
            self.logger.info("Connecting to database...")

            try:
                self.dbManager.connect()
                self.logger.info("Connected.")
                connected = True
            except Exception as e:
                if self.appInfo.applicationQuitting:
                    return

                print(f"Error: {str(e)}")
                sleep(2)
                self.logger.info("Failed to connect. Retrying...")
                sleep(1)
                continue

        if not connected:
            qt_util.runInMainThread(self.onDBManagerConnectionTimeout)
            return

        self.onDBManagerConnected()
Esempio n. 2
0
    def onDBManagerConnected(self):
        self.initHostProcessController()

        self.initServices()
        self.load()
        self.appInfo.initialized = True

        if self.mode == ApplicationMode.GUI:
            qt_util.runInMainThread(self.loaderWindow.hide)
            qt_util.runInMainThread(self.setupMainWindowManager)
 def updateInfo(self, info):
     qt_util.runInMainThread(self.widget.refreshConnectionButton.setText,
                             "Connecting...")
     qt_util.runInMainThread(self.widget.refreshConnectionButton.setEnabled,
                             False)
     self.deadlineService.updateInfo(info)
     self.deadlineService.connect()
     qt_util.runInMainThread(self.widget.refreshConnectionButton.setText,
                             "Refresh Connection")
     qt_util.runInMainThread(self.widget.refreshConnectionButton.setEnabled,
                             True)
Esempio n. 4
0
    def viewItems(self, saveSearchHistoryEntry = True):
        if len(self.documentTableModel.displayedKeys) == 0:
            return

        qt_util.runInMainThread(self.widget.findPushButton.setEnabled, False)

        qt_util.runInMainThread(self.documentTableModel.clear)
        maxDisplayedItems = "computing..."
        qt_util.runInMainThread(lambda: self.mainWindow.itemCountLabel.setText("Item Count: " + str(maxDisplayedItems)))

        if maxDisplayedItems == 0:
            qt_util.runInMainThread(self.widget.findPushButton.setEnabled, True)
            return
        
        self.initDocumentProgress(maxDisplayedItems)
        self.updateDocumentProgress(1)

        entries = []
        i = 0
        try:
            for collectionName in self.collectionViewer.yieldSelectedCollectionNames():
                for item in self.getFilteredDocumentsOfCollection(collectionName):
                    if self.appInfo.applicationQuitting:
                        return

                    i += 1
                    tableEntry = self.extractTableEntry(self.documentTableModel.displayedKeys, item)
                    entries.append(tableEntry)
        except Exception as e:
            self.logger.error(f'Failed to retrieve filtered items. Reason: {str(e)}')
        
        qt_util.runInMainThread(self.documentTableModel.addEntries, entries)
        self.initDocumentProgress(i if i > 0 else 1)
        qt_util.runInMainThread(lambda:self.mainWindow.itemCountLabel.setText("Item Count: " + str(i)))
        self.updateDocumentProgress(0.0)

        qt_util.runInMainThread(self.widget.findPushButton.setEnabled, True)
        if saveSearchHistoryEntry:
            qt_util.runInMainThread(self.addCurrentSearchHistoryEntry)
Esempio n. 5
0
 def initDocumentProgress(self, maxVal):
     if not isinstance(maxVal, int):
         maxVal = 0
         
     qt_util.runInMainThread(self.widget.documentProgressBar.setMaximum, maxVal)
Esempio n. 6
0
 def updateDocumentProgress(self, val):
     qt_util.runInMainThread(self.widget.documentProgressBar.setValue, val)
Esempio n. 7
0
 def emit(self, record):
     msg = self.format(record)
     qt_util.runInMainThread(self.textWidget.setText, msg)