def updateAll(mydb): lastImport = mydb.getConfig('lastEDDBimport') if lastImport: lastImport = datetime.strptime(lastImport, "%Y-%m-%d %H:%M:%S") ''' omly update max all 24h or next dey >5 plus random anti ddos "not all clients start update at same time hope it work ;)" ''' updatetime = datetime.utcnow().replace(hour=3, minute=30) if lastImport < updatetime and datetime.utcnow( ) > updatetime and random.randint(1, 10) == 1: pass else: return print("update from eddb") try: myapiv4 = apiv4.loader(mydb) myapiv4.importData() del myapiv4 except: traceback.print_exc() mydb.setConfig('plugin_eddb', 0) print("disable eddb loader!") mydb.setConfig('lastEDDBimport', datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S"))
def updateAll(mydb): lastImport = mydb.getConfig( 'lastEDDBimport' ) if lastImport: lastImport = datetime.strptime(lastImport, "%Y-%m-%d %H:%M:%S") ''' omly update max all 24h or next dey >5 plus random anti ddos "not all clients start update at same time hope it work ;)" ''' updatetime = datetime.utcnow().replace(hour=3, minute=30) if lastImport < updatetime and datetime.utcnow() > updatetime and random.randint(1, 10) == 1: pass else: return print("update from eddb") try: myapiv4 = apiv4.loader(mydb) myapiv4.importData() del myapiv4 except: traceback.print_exc() mydb.setConfig('plugin_eddb', 0) print("disable eddb loader!") mydb.setConfig( 'lastEDDBimport', datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") )
def forceEDDBimport(self): msg = "Are you sure that you want to update the system data forced?" msg += "\n\nThe update is performed directly and not in the background! Please do not close the application, it might take a moment." msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Information, "Force EDDB import", msg, QtGui.QMessageBox.NoButton, self) msgBox.addButton("Import", QtGui.QMessageBox.AcceptRole) msgBox.addButton("Cancel", QtGui.QMessageBox.RejectRole) if msgBox.exec_() == QtGui.QMessageBox.AcceptRole: from elite.loader.eddb import apiv4 self.lockDB() myapiv4 = apiv4.loader(self.mydb) myapiv4.importData(forceImport=True) del myapiv4 self.unlockDB() self.mydb.setConfig( 'lastEDDBimport', datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") )