def onTimerEvent(self): self._updateIfNeededEDDB() analyzerupdated = self._checkCurrentStatus() edceupdated = self._checkEDCE() self._checkVerificationWindow() if self.edce is not None: self.edceUpToDateLabel.setText('EDCE') if edceupdated: self.edceUpToDateLabel.setStyleSheet( "background:rgb(128,255,128)") else: self.edceUpToDateLabel.setStyleSheet( "background:rgb(255,128,128)") if edceupdated: now = datetime.datetime.now().timestamp() #print("edceupdated ",now-self.edce.resultsLastUpdated) if now - self.edce.resultsLastUpdated < 1 and Options.get( "search-auto-edce-enabled", "1") == '1': self._setCurrentSystemToTabs() elif analyzerupdated: #print("analyzerupdated") if Options.get("search-auto-log-enabled", "0") == '1': self._setCurrentSystemToTabs()
def _updateEdceInstance(self): self.edce = None try: postMarketData = Options.get("EDCE-uploads-results", "1") != "0" self.edce = EdceWrapper.EdceWrapper(Options.get("EDCE-path", ""), self.db, postMarketData, self._verificationCheck) self.edce.addFinishedListener(self._edceUpdated) except Exception as ex: print(ex)
def _updateIfNeededEDDB(self): interval = int(Options.get("EDDB-check-interval", 1)) lastUpdated = int(Options.get("EDDB-last-updated", -1)) now = datetime.datetime.now().timestamp() if interval <= 0: return if lastUpdated <= 0 or now - lastUpdated > interval * 60 * 60: ThreadWorker.ThreadWorker(lambda: EDDB.update(self.db)).start() self._checkUpdate()
def _updateIfNeededEDDB(self): interval = int(Options.get("EDDB-check-interval", 1)) lastUpdated = int(Options.get("EDDB-last-updated", -1)) now = datetime.datetime.now().timestamp() if interval <= 0: return if lastUpdated <= 0 or now - lastUpdated > interval * 60 * 60: ThreadWorker.ThreadWorker(lambda :EDDB.update(self.db)).start() self._checkUpdate()
def __init__(self, db): super(QtWidgets.QMainWindow, self).__init__() self.setupUi(self) self._setupLog() self.currentStatus = None self.optionsMenu.triggered.connect(self._optionsMenuSelected) self.exitMenu.triggered.connect(self._exitMenuSelected) self.searchMenuItem.triggered.connect(self._addSearchTabSelected) self.statusMenuItem.triggered.connect(self._addStatusTabSelected) self.commodityMenuItem.triggered.connect(self._addCommodityTabSelected) self.guideMenuItem.triggered.connect(self._addGuideTabSelected) self.edceFinished.connect(self.onEdceUpdated) self.db = db self.analyzer = EliteLogAnalyzer.EliteLogAnalyzer() self.analyzer.setPath(Options.get("Elite-path", "")) self._updateEdceInstance() self.edceLastUpdated = int(datetime.datetime.now().timestamp()) -self._edceUpdateTimeout +15 self.edceLastUpdateInfo = None self.verificationCode = None self.startVerification = False self.sounds=Sounds.Sounds() self.timer = QtCore.QTimer(self) self.timer.timeout.connect(self.onTimerEvent) self.timer.start(1000) self.tabItems = [] self.mainTab.setTabsClosable(True) self.mainTab.tabCloseRequested.connect(self._onTabClosing) #self.mainTab.currentChanged.connect(self._onTabChanged) newbutton=QtWidgets.QPushButton("New Search",self.mainTab) newbutton.clicked.connect(self._addSearchTabSelected) buttonlayout=QtWidgets.QStackedLayout() buttonlayout.addWidget(newbutton) buttonwidget=QtWidgets.QWidget() buttonwidget.setLayout(buttonlayout) self.mainTab.setCornerWidget ( buttonwidget, 0) self.edceState = "notStation" if self.db.dbEmpty: print("db load failed or doesn't exist - downloading...") self.dbupdated.connect(self.loadSettingsAndUI) # display 'db downloading' tab self.mainTab.clear() widget=ui.DBloadingTab.DBloadingTab(self.db, self.analyzer, "", self) widget.setTabName(str(1)) #item = (widget.getTabName(), widget) self.mainTab.addTab(widget, QtGui.QIcon(), 'DB loading...') self.mainTab.setEnabled(False) ThreadWorker.ThreadWorker(lambda: EDDB.update(self.db,force=True), lambda result: self.dbupdated.emit() ).start() else: self.loadSettingsAndUI() self._checkUpdate()
def onTimerEvent(self): self._updateIfNeededEDDB() analyzerupdated=self._checkCurrentStatus() edceupdated=self._checkEDCE() self._checkVerificationWindow() if self.edce is not None: self.edceUpToDateLabel.setText('EDCE') if edceupdated: self.edceUpToDateLabel.setStyleSheet("background:rgb(128,255,128)") else: self.edceUpToDateLabel.setStyleSheet("background:rgb(255,128,128)") if edceupdated: now = datetime.datetime.now().timestamp() #print("edceupdated ",now-self.edce.resultsLastUpdated) if now-self.edce.resultsLastUpdated<1 and Options.get("search-auto-edce-enabled", "1")=='1': self._setCurrentSystemToTabs() elif analyzerupdated: #print("analyzerupdated") if Options.get("search-auto-log-enabled", "0")=='1': self._setCurrentSystemToTabs()
def _readSettings(self): versionstring = "?" try: with open("version.txt", "r") as f: versionstring = f.readline() except IOError: print("could not read version file") self.setWindowTitle("Elite Merchant v" + versionstring) Options.set("Merchant-version", versionstring) self.restoreGeometry( Options.get("MainWindow-geometry", QtCore.QByteArray())) self.restoreState(Options.get("MainWindow-state", QtCore.QByteArray())) self.cargoSizeSpinBox.setValue( int(Options.get("ship_cargo_size", "100"))) self.jumpRangeSpinBox.setValue( float(Options.get("ship_jump_range", "16"))) self.minPadSizeCombo.setCurrentIndex( int(Options.get("ship_landing_pad_size", "0"))) tabCount = int(Options.get("main_window_tab_count", "0")) for index in range(tabCount): type = Options.get("main_window_tab_{0}_type".format(index), "") if type == "search": item = ("Search {0}".format(index + 1), ui.SearchTab.SearchTab(self.db, self.analyzer, str(index + 1), self)) elif type == "status": item = ("Status {0}".format(index + 1), ui.Status.Status(self.db, self.analyzer, str(index + 1), self)) elif type == "guide": item = ("User Guide", ui.GuideTab.GuideTab(self.db, self.analyzer, "", self)) elif type == "commodity": item = ("Commodities {0}".format(index + 1), ui.CommodityTab.CommodityTab(self.db, self.analyzer, str(index + 1), self)) self.tabItems.append(item) if len(self.tabItems) == 0: self._addGuideTabSelected()
def _readSettings(self): versionstring="?" try: with open("version.txt", "r") as f: versionstring = f.readline() except IOError: print("could not read version file") self.setWindowTitle("Elite Merchant v"+versionstring) Options.set("Merchant-version",versionstring) self.restoreGeometry(Options.get("MainWindow-geometry", QtCore.QByteArray())) self.restoreState(Options.get("MainWindow-state", QtCore.QByteArray())) self.cargoSizeSpinBox.setValue(int(Options.get("ship_cargo_size", "100"))) self.jumpRangeSpinBox.setValue(float(Options.get("ship_jump_range", "16"))) self.minPadSizeCombo.setCurrentIndex(int(Options.get("ship_landing_pad_size", "0"))) tabCount = int(Options.get("main_window_tab_count", "0")) for index in range(tabCount): type = Options.get("main_window_tab_{0}_type".format(index), "") if type == "search": item = ("Search {0}".format(index + 1), ui.SearchTab.SearchTab(self.db, self.analyzer, str(index + 1),self)) elif type == "status": item = ("Status {0}".format(index + 1), ui.Status.Status(self.db, self.analyzer, str(index + 1),self)) elif type == "guide": item = ("User Guide", ui.GuideTab.GuideTab(self.db, self.analyzer, "", self)) elif type == "commodity": item = ("Commodities {0}".format(index + 1), ui.CommodityTab.CommodityTab(self.db, self.analyzer, str(index + 1),self)) self.tabItems.append(item) if len(self.tabItems)==0: self._addGuideTabSelected()
def __init__(self, db): super(QtWidgets.QMainWindow, self).__init__() self.setupUi(self) self._setupLog() self.currentStatus = None self.optionsMenu.triggered.connect(self._optionsMenuSelected) self.exitMenu.triggered.connect(self._exitMenuSelected) self.searchMenuItem.triggered.connect(self._addSearchTabSelected) self.statusMenuItem.triggered.connect(self._addStatusTabSelected) self.commodityMenuItem.triggered.connect(self._addCommodityTabSelected) self.guideMenuItem.triggered.connect(self._addGuideTabSelected) self.edceFinished.connect(self.onEdceUpdated) self.db = db self.analyzer = EliteLogAnalyzer.EliteLogAnalyzer() self.analyzer.setPath(Options.get("Elite-path", "")) self._updateEdceInstance() self.edceLastUpdated = int( datetime.datetime.now().timestamp()) - self._edceUpdateTimeout + 15 self.edceLastUpdateInfo = None self.verificationCode = None self.startVerification = False self.sounds = Sounds.Sounds() self.timer = QtCore.QTimer(self) self.timer.timeout.connect(self.onTimerEvent) self.timer.start(1000) self.tabItems = [] self.mainTab.setTabsClosable(True) self.mainTab.tabCloseRequested.connect(self._onTabClosing) #self.mainTab.currentChanged.connect(self._onTabChanged) newbutton = QtWidgets.QPushButton("New Search", self.mainTab) newbutton.clicked.connect(self._addSearchTabSelected) buttonlayout = QtWidgets.QStackedLayout() buttonlayout.addWidget(newbutton) buttonwidget = QtWidgets.QWidget() buttonwidget.setLayout(buttonlayout) self.mainTab.setCornerWidget(buttonwidget, 0) self.edceState = "notStation" if self.db.dbEmpty: print("db load failed or doesn't exist - downloading...") self.dbupdated.connect(self.loadSettingsAndUI) # display 'db downloading' tab self.mainTab.clear() widget = ui.DBloadingTab.DBloadingTab(self.db, self.analyzer, "", self) widget.setTabName(str(1)) #item = (widget.getTabName(), widget) self.mainTab.addTab(widget, QtGui.QIcon(), 'DB loading...') self.mainTab.setEnabled(False) ThreadWorker.ThreadWorker( lambda: EDDB.update(self.db, force=True), lambda result: self.dbupdated.emit()).start() else: self.loadSettingsAndUI() self._checkUpdate()