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 _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 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 __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 closeEvent(self, event): self.sounds.quit() # unload soundsystem for tab in self.tabItems: # shut down any searches in progress if tab[1].getType() == "search": tab[1].cancelSearch() index = 0 for name, widget in self.tabItems: if widget.getType() == 'update': # don't save updatewindows continue Options.set("main_window_tab_{0}_type".format(index), widget.getType()) widget.dispose() index += 1 Options.set("main_window_tab_count", index) Options.set("ship_cargo_size", self.cargoSizeSpinBox.value()) Options.set("ship_jump_range", self.jumpRangeSpinBox.value()) Options.set("ship_landing_pad_size", self.minPadSizeCombo.currentIndex()) Options.set("MainWindow-geometry", self.saveGeometry()) Options.set("MainWindow-state", self.saveState()) print("Waiting for EDCE fetch to complete") self.timer.stop() if self.edce is not None: self.edce.join()
parser.add_argument( "-i", action="store", dest="inputhalofilelistname", help= "The filelist containing a list of the base filenames for VELOCIraptor output (e.g. /path/to/VELOCIraptor/output/snapshot_###.VELOCIraptor)", required=True) parser.add_argument("-o", action="store", dest="outfilebasename", help="The base name for the output catalogs", required=True) tmpOpt = parser.parse_args() #store number of snaps opt = Options(tmpOpt) #Get the name of the datasets for the desired input format inputfields = GetDatasetNames(opt, basecodedir) #Load in the VELOCIraptor halodata and tree atime, numhalos, halodata, tree, unitdata, cosmodata = ReadVELOCIraptorTreeandHalodata( opt, inputfields) # built KD tree to quickly search for near neighbours. only build if not passed. start = time.time() pos_tree = [[] for j in range(opt.numsnaps)] start = time.time() if (opt.iverbose): print("KD tree build") for snap in range(opt.numsnaps - 1, -1, -1): if (numhalos[snap] > 0):
def closeEvent(self, event): self.sounds.quit() # unload soundsystem for tab in self.tabItems: # shut down any searches in progress if tab[1].getType() == "search": tab[1].cancelSearch() index = 0 for name, widget in self.tabItems: if widget.getType()=='update': # don't save updatewindows continue Options.set("main_window_tab_{0}_type".format(index), widget.getType()) widget.dispose() index += 1 Options.set("main_window_tab_count", index) Options.set("ship_cargo_size", self.cargoSizeSpinBox.value()) Options.set("ship_jump_range", self.jumpRangeSpinBox.value()) Options.set("ship_landing_pad_size", self.minPadSizeCombo.currentIndex()) Options.set("MainWindow-geometry", self.saveGeometry()) Options.set("MainWindow-state", self.saveState()) print("Waiting for EDCE fetch to complete") self.timer.stop() if self.edce is not None: self.edce.join()
def w_options(self): self.window = QtWidgets.QMainWindow() self.ui = Options.Ui_MainWindow() self.ui.setupUi(self.window) self.window.show()