def createNewDb(self, newDbName): """ """ sharedFunctions.createResultsDirStr(newDbName) dbPath = sharedFunctions.getDbPath(newDbName) odbMetadata = self.createOdbMetadata() db = shelve.open(dbPath) db["metadata"] = odbMetadata db.close() self.dbList.appendItem(text=newDbName)
def updateWidgets(self): """ """ dbPath = sharedFunctions.getDbPath(self.form.kw["dbName"].getValue()) db = shelve.open(dbPath, 'r') metadata = db["metadata"] numEntries = len(db.keys()) - 1 db.close() self.description.setText(metadata["description"]) self.crackType.setText(metadata["crackType"]) self.loads.setText(metadata["loads"]) self.scanner.setTotal(numEntries)
def __init__(self, form): """ """ self.form = form self.db = sharedFunctions.getDbPath(self.form.kw["dbName"].getValue()) title = "Database Browser: {0}".format( self.form.kw["dbName"].getValue()) AFXDataDialog.__init__( self, form, title, self.APPLY | self.DISMISS, DIALOG_ACTIONS_SEPARATOR | DIALOG_ACTIONS_RIGHT | DECOR_RESIZE) applyButton = self.getActionButton(self.ID_CLICKED_APPLY) applyButton.setText("Create") self.getDbMetadata() self.createWidgets()
def readFromDb(**kargs): """ """ dbKeys = kargs["dbKeys"].split("_") dbPath = sharedFunctions.getDbPath(kargs["dbName"]) analytical = () analysis = () for key in kargs: if kargs[key] is True: if "analysis" in key: analysis += key[:-8], if "analytical" in key: analytical += key[:-10], contours = kargs["contoursToAverage"].split(",") contoursToAverage = () for key in contours: newKey = key.replace(" ", "_") contoursToAverage += newKey, requests = { "contoursToAverage": contoursToAverage, "includeContours": kargs["includeContours"], "analysisKeys": analysis, "analyticalKeys": analytical} info = {} for dbKey in dbKeys: db = shelve.open(dbPath, 'r') data = db[dbKey] db.close() dataStr = prepareDbDataStr(data, requests, dbKey) calcAnalyticalSolutions(dataStr) if kargs["XYPlotData"]: createXYPlots(dataStr) if kargs["printData"]: printData(dataStr) if kargs["VisualizationOdb"]: createVisualizationOdb(dataStr)
def checkCompatibility(self, db): """ """ dbPath = sharedFunctions.getDbPath(db) db = shelve.open(dbPath, 'r') dbMeta = db["metadata"] db.close() odbMeta = self.createOdbMetadata() print "odbMetadata", odbMeta print "dbMetadata", dbMeta equal = True if str(odbMeta["dbVersion"]) != str(dbMeta["dbVersion"]): return False else: if odbMeta["crackType"] != dbMeta["crackType"]: return False if odbMeta["loads"] != dbMeta["loads"]: return False odbMeta["historyOutputs"].sort() dbMeta["historyOutputs"].sort() if odbMeta["historyOutputs"] != dbMeta["historyOutputs"]: return False return True
def specifyActiveShelve(self, dbName): """ """ self.dbName = dbName self.activeShelve = sharedFunctions.getDbPath(dbName)