Python qgis.core.QgsMessageLog.logMessage() Examples
The following are 30
code examples of qgis.core.QgsMessageLog.logMessage().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
qgis.core.QgsMessageLog
, or try the search function
.
Example #1
Source File: connectionComboBox.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def loadDatabase(self, idx): """ Loads the selected database """ try: if self.abstractDb is not None: self.closeDatabase() if self.serverAbstractDb is not None and idx > 0: if not self.instantiateAbstractDb: self.abstractDb = self.abstractDbFactory.createDbFactory(DsgEnums.DriverPostGIS) (host, port, user, password) = self.serverAbstractDb.getDatabaseParameters() dbName = self.connectionSelectorComboBox.itemText(idx).split(' (')[0] self.abstractDb.connectDatabaseWithParameters(host, port, dbName, user, password) self.abstractDb.checkAndOpenDb() self.dbChanged.emit(self.abstractDb) self.connectionChanged.emit() except Exception as e: self.closeDatabase() self.problemOccurred.emit(self.tr('A problem occurred! Check log for details.')) QgsMessageLog.logMessage(':'.join(e.args), "DSGTools Plugin", Qgis.Critical)
Example #2
Source File: ConnectionManager.py From qgis-cartodb with GNU General Public License v2.0 | 6 votes |
def editConnectionDialog(self): # Modify existing connection. currentText = self.ui.connectionList.currentText() apiKey = self.settings.value('/CartoDBPlugin/%s/api' % currentText) multiuser = self.settings.value('/CartoDBPlugin/%s/multiuser' % currentText, False) QgsMessageLog.logMessage('Multiuser:' + str(multiuser) + ' - ' + str(bool(multiuser)), 'CartoDB Plugin', QgsMessageLog.INFO) conEdit = CartoDBNewConnectionDialog(currentText) conEdit.setWindowTitle(QApplication.translate('CartoDBPlugin', 'Edit CartoDB Connection')) conEdit.ui.userTX.setText(currentText) conEdit.ui.apiKeyTX.setText(apiKey) conEdit.ui.multiuserCH.setChecked(str(multiuser) in ['true', '1', 'True']) result = conEdit.exec_() if result == QDialog.Accepted: # Update connection list self.populateConnectionList()
Example #3
Source File: load_by_class.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def listClassesFromDatabase(self): ''' List all classes from database ''' self.classes = [] self.classesListWidget.clear() self.dbVersion = self.widget.getDBVersion() self.qmlPath = self.widget.getQmlPath() self.parentClassList = self.widget.abstractDb.getOrphanGeomTablesWithElements(loading = True) self.classes = [] try: self.classes = self.widget.abstractDb.listGeomClassesFromDatabase() except Exception as e: self.bar.pushMessage(self.tr("CRITICAL!"), self.tr('A problem occurred! Check log for details.'), level=QgsMessageBar.CRITICAL) QgsMessageLog.logMessage(':'.join(e.args), 'DSGTools Plugin', Qgis.Critical) if self.onlyParentsCheckBox.isChecked() and not self.widget.isSpatialite: self.classesListWidget.addItems(self.parentClassList) else: self.classesListWidget.addItems(self.classes) self.classesListWidget.sortItems()
Example #4
Source File: create_profile.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def getDbInfo(self): """ Gets database info. This info is used to create a profile model that will be adjusted by the user """ currentPath = os.path.dirname(__file__) if self.versionCombo.currentText() == '2.1.3': edgvPath = os.path.join(currentPath, '..', 'DbTools', 'SpatialiteTool', 'template', '213', 'seed_edgv213.sqlite') elif self.versionCombo.currentText() == 'FTer_2a_Ed': edgvPath = os.path.join(currentPath, '..', 'DbTools', 'SpatialiteTool', 'template', 'FTer_2a_Ed', 'seed_edgvfter_2a_ed.sqlite') self.abstractDb = self.abstractDbFactory.createDbFactory(DsgEnums.DriverSpatiaLite) if not self.abstractDb: QtWidgets.QMessageBox.warning(self, self.tr('Warning!'), self.tr('A problem occurred! Check log for details.')) return self.abstractDb.connectDatabase(edgvPath) try: self.abstractDb.checkAndOpenDb() except Exception as e: QtWidgets.QMessageBox.critical(self, self.tr('Critical!'), self.tr('A problem occurred! Check log for details.')) QgsMessageLog.logMessage(':'.join(e.args), 'DSGTools Plugin', Qgis.Critical)
Example #5
Source File: newConnectionLineEdit.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def loadDatabase(self, currentText): """ Loads the selected database """ try: if not self.currentDb(): # in case no datasource was selected return self.setAbstractDb() msg = self.validate() self.dbChanged.emit(self.abstractDb) self.connectionChanged.emit() # if msg: # raise Exception(msg) except Exception as e: self.problemOccurred.emit(self.tr('A problem occurred! Check log for details.')) QgsMessageLog.logMessage(':'.join(e.args), "DSGTools Plugin", Qgis.Critical)
Example #6
Source File: datasourceConversion.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def validate(self): """ Verifies contents displayed on mapping table in order to infer its validity as datasource conversion map. :return: (bool) map validity status. """ # validate map msg = self.invalidatedReason() if msg: # if an invalidation reason was given, warn user and nothing else. msgBar = QgsMessageBar(self) # if window is resized, msgBar stays, not ideal, but works for now # maybe we should connect to some parent resizing signal or something... msgBar.resize(QSize(self.geometry().size().width(), msgBar.geometry().height())) msgBar.pushMessage(self.tr('Warning!'), msg, level=Qgis.Warning, duration=5) QgsMessageLog.logMessage(msg, 'DSGTools Plugin', Qgis.Critical) return msg == ''
Example #7
Source File: CartoDBLayer.py From qgis-cartodb with GNU General Public License v2.0 | 6 votes |
def _updateGeometries(self, changedGeometries): for featureID, geom in changedGeometries.iteritems(): QgsMessageLog.logMessage('Update geometry for feature ID: ' + str(featureID), 'CartoDB Plugin', QgsMessageLog.INFO) request = QgsFeatureRequest().setFilterFid(featureID) try: sql = "UPDATE " + self._schema() + self.cartoTable + " SET the_geom = " feature = self.getFeatures(request).next() sql = sql + "ST_GeomFromText('" + geom.exportToWkt() + "', ST_SRID(the_geom)) WHERE cartodb_id = " + unicode(feature['cartodb_id']) sql = sql.encode('utf-8') res = self._updateSQL(sql, 'Some error ocurred updating geometry') if isinstance(res, dict) and res['total_rows'] == 1: self.iface.messageBar().pushMessage('Info', 'Geometry for cartodb_id ' + str(feature['cartodb_id']) + ' was updated from ' + str(self.cartoTable) + ' at CartoDB servers', level=self.iface.messageBar().INFO, duration=10) except StopIteration: self.iface.messageBar().pushMessage('Warning', 'Can\'t get feature with fid ' + str(featureID), level=self.iface.messageBar().WARNING, duration=10)
Example #8
Source File: CartoDBLayer.py From qgis-cartodb with GNU General Public License v2.0 | 6 votes |
def _deleteFeatures(self, deletedFeatureIds): provider = self.dataProvider() for featureID in deletedFeatureIds: QgsMessageLog.logMessage('Delete feature with feature ID: ' + str(featureID), 'CartoDB Plugin', QgsMessageLog.INFO) request = QgsFeatureRequest().setFilterFid(featureID) try: feature = provider.getFeatures(request).next() sql = "DELETE FROM " + self._schema() + self.cartoTable + " WHERE cartodb_id = " + unicode(feature['cartodb_id']) res = self._updateSQL(sql, 'Some error ocurred deleting feature') if isinstance(res, dict) and res['total_rows'] == 1: self.iface.messageBar().pushMessage('Info', 'Feature with cartodb_id ' + str(feature['cartodb_id']) + ' was deleted from ' + str(self.cartoTable) + ' at CartoDB servers', level=self.iface.messageBar().INFO, duration=10) except StopIteration: self.iface.messageBar().pushMessage('Warning', 'Can\'t get feature from dataprovider with fid ' + str(featureID), level=self.iface.messageBar().WARNING, duration=10) self._deletedFeatures = []
Example #9
Source File: shapefileLayerLoader.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def loadLayer(self, inputParam, parentNode, uniqueLoad, stylePath, domLayerDict): """ Loads a layer :param lyrName: Layer nmae :param idSubgrupo: sub group id :param uniqueLoad: boolean to mark if the layer should only be loaded once :param stylePath: path to the styles used :param domLayerDict: domain dictionary :return: """ lyrName, schema, geomColumn, tableName, srid = self.getParams(inputParam) lyr = self.checkLoaded(tableName) if uniqueLoad and lyr: return lyr self.setDataSource('', '_'.join([schema,tableName]), geomColumn, '') vlayer = QgsVectorLayer(self.uri.uri(), tableName, self.provider) QgsProject.instance().addMapLayer(vlayer, addToLegend = False) crs = QgsCoordinateReferenceSystem(int(srid), QgsCoordinateReferenceSystem.EpsgCrsId) vlayer.setCrs(crs) vlayer = self.setDomainsAndRestrictionsWithQml(vlayer) vlayer = self.setMulti(vlayer,domLayerDict) if stylePath: fullPath = self.getStyle(stylePath, tableName) if fullPath: vlayer.loadNamedStyle(fullPath, True) parentNode.addLayer(vlayer) if not vlayer.isValid(): QgsMessageLog.logMessage(vlayer.error().summary(), "DSGTools Plugin", Qgis.Critical) vlayer = self.createMeasureColumn(vlayer) return vlayer
Example #10
Source File: newDatabaseLineEdit.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def loadDatabase(self, currentText): """ Loads the selected database. currentText: (str) text as shown on datasource combo box. """ try: if not self.currentDb(): # in case no datasource was selected return self.setAbstractDb() msg = self.validate() self.dbChanged.emit(self.abstractDb) self.connectionChanged.emit() # if msg: # raise Exception(msg) except Exception as e: self.problemOccurred.emit(self.tr('A problem occurred! Check log for details.')) QgsMessageLog.logMessage(':'.join(e.args), "DSGTools Plugin", Qgis.Critical)
Example #11
Source File: CartoDBPlugin.py From qgis-cartodb with GNU General Public License v2.0 | 6 votes |
def addSQL(self): # Create and show the dialog dlg = CartoDBNewSQLDialog(self.toolbar) dlg.show() result = dlg.exec_() if result == 1 and dlg.currentUser is not None and dlg.currentApiKey is not None: sql = dlg.getQuery() progressMessageBar, progress = self.addLoadingMsg(1) QgsMessageLog.logMessage('SQL: ' + sql, 'CartoDB Plugin', QgsMessageLog.INFO) layer = CartoDBLayer(self.iface, 'SQLQuery', dlg.currentUser, dlg.currentApiKey, sql=sql, isSQL=True) QgsMapLayerRegistry.instance().addMapLayer(layer) self.layers.append(layer) progress.setValue(1) self.iface.mainWindow().statusBar().clearMessage() self.iface.messageBar().popWidget(progressMessageBar)
Example #12
Source File: databaseFileLineEdit.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def loadDatabase(self, currentText): """ Loads the selected database """ try: if not self.currentDb(): # in case no datasource was selected self.closeDatabase() elif not self.instantiateAbstractDb: self.abstractDb = self.abstractDbFactory.createDbFactory(self.driver) self.abstractDb.connectDatabase(conn=currentText) self.abstractDb.checkAndOpenDb() self.dbChanged.emit(self.abstractDb) self.connectionChanged.emit() except Exception as e: self.closeDatabase() self.problemOccurred.emit(self.tr('A problem occurred! Check log for details.')) QgsMessageLog.logMessage(':'.join(e.args), "DSGTools Plugin", Qgis.Critical)
Example #13
Source File: mainfunction.py From dzetsaka with GNU General Public License v3.0 | 6 votes |
def pushFeedback(message, feedback=None): isNum = isinstance(message, (float, int)) if feedback and feedback is not True: if feedback == 'gui': if not isNum: QgsMessageLog.logMessage(str(message)) else: if isNum: feedback.setProgress(message) else: feedback.setProgressText(message) else: if not isNum: print(str(message)) """ else: print(52*"=") print(((int(message/2)-3)*'-'+(str(message)+'%'))) print(52*"=") """
Example #14
Source File: logger.py From orstools-qgis-plugin with MIT License | 6 votes |
def log(message, level_in=0): """ Writes to QGIS inbuilt logger accessible through panel. :param message: logging message to write, error or URL. :type message: str :param level_in: integer representation of logging level. :type level_in: int """ if level_in == 0: level = Qgis.Info elif level_in == 1: level = Qgis.Warning elif level_in == 2: level = Qgis.Critical else: level = Qgis.Info QgsMessageLog.logMessage(message, PLUGIN_NAME.strip(), level)
Example #15
Source File: field_toolbox.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def checkConditions(self): """ Check the conditions to see if the tool can be used """ if not self.widget.abstractDb: QMessageBox.critical(self, self.tr('Critical!'), self.tr('Please, select a database.')) return False try: version = self.widget.abstractDb.getDatabaseVersion() except Exception as e: QMessageBox.critical(self, self.tr('Critical!'), self.tr('Problem obtaining database version! Please, check log for details.')) QgsMessageLog.logMessage(':'.join(e.args), "DSGTools Plugin", Qgis.Critical) return False if 'version' not in list(self.reclassificationDict.keys()): QMessageBox.critical(self, self.tr('Critical!'), self.tr('File not formated propperly.')) return False if self.reclassificationDict['version'] != version: QMessageBox.critical(self, self.tr('Critical!'), self.tr('Database version does not match the field toolbox version.')) return False return True
Example #16
Source File: exploreServerWidget.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def getDbsFromServer(self, name): """ Gets server databases name: server name """ gen = self.factory.createSqlGenerator(driver=DsgEnums.DriverPostGIS) (host, port, user, password) = self.getServerConfiguration(name) database = 'postgres' postgisDb = self.dbFactory.createDbFactory(DsgEnums.DriverPostGIS) postgisDb.connectDatabaseWithParameters(host, port, database, user, password) if not postgisDb.db.open(): QgsMessageLog.logMessage(db.lastError().text(), "DSGTools Plugin", Qgis.Critical) QMessageBox.critical(self.iface.mainWindow(), self.tr('Critical'), self.tr('A problem occurred! Check log for details.')) query = QSqlQuery(gen.getDatabasesFromServer(), postgisDb.db) if not query.isActive(): QMessageBox.critical(self.iface.mainWindow(), self.tr('Critical'), self.tr("Problem executing query: ")+query.lastError().text()) dbList = [] while query.next(): dbList.append(query.value(0)) postgisDb.closeDatabase() return self.browseServer(dbList, host, port, user, password)
Example #17
Source File: complexWindow.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def loadAssociatedFeatures(self): """ Loads all features associated to a complex """ self.treeWidget.clear() if self.complexCombo.currentIndex() == 0: return complex = self.complexCombo.currentText() associatedDict = dict() try: associatedDict = self.abstractDb.loadAssociatedFeatures(complex) except Exception as e: QMessageBox.critical(self.iface.mainWindow(), self.tr('Critical'), self.tr('A problem occurred! Check log for details.')) QgsMessageLog.logMessage(':'.join(e.args), 'DSGTools Plugin', Qgis.Critical) for name in list(associatedDict.keys()): for complex_uuid in list(associatedDict[name].keys()): self.addAssociatedFeature(complex, name, complex_uuid, None, None) for aggregated_class in associatedDict[name][complex_uuid]: for ogc_fid in associatedDict[name][complex_uuid][aggregated_class]: self.addAssociatedFeature(complex, name, complex_uuid, aggregated_class, ogc_fid)
Example #18
Source File: exceptions.py From qfieldsync with GNU Lesser General Public License v3.0 | 6 votes |
def __init__(self, message, exception=None, long_message=None, tag="QFieldSync"): """ an Exception that automatically logs the error to the QgsMessageLog :param exception: :param message: a short message to be logged and used by str() :param long_message: a longer message only shown in the log """ # Call the base class constructor with the parameters it needs super(QFieldSyncError, self).__init__(message) self.message = message self.exception = exception self.long_message = long_message log_message = self.message if self.long_message is not None: log_message = "\nDetails:\n %s" % self.long_message if self.exception is not None: log_message = "\nException:\n %s" % self.long_message QgsMessageLog.logMessage(log_message, tag, Qgis.Critical)
Example #19
Source File: complexWindow.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def updateLayerOnDisassociate(self, layer, aggregated_class, link_column, id): """ Updates the layer upon disassociation from complex layer: layer that will be afected aggregated_class: aggregated class link_column: link column between complex and class id: feature id """ try: if self.abstractDb.isComplexClass(aggregated_class): self.abstractDb.disassociateComplexFromComplex(aggregated_class, link_column, id) else: #field index that will be set to NULL fieldIndex = [i for i in range(len(layer.dataProvider().fields())) if layer.dataProvider().fields()[i].name() == link_column] #attribute pair that will be changed attrs = {fieldIndex[0]:None} #actual update in the database layer.dataProvider().changeAttributeValues({int(id):attrs}) except Exception as e: QMessageBox.critical(self.iface.mainWindow(), self.tr("Critical!"), e.args[0]) QgsMessageLog.logMessage(':'.join(e.args), 'DSGTools Plugin', Qgis.Critical)
Example #20
Source File: utils.py From qgis-earthengine-plugin with MIT License | 6 votes |
def update_ee_image_layer(image, layer, shown=True, opacity=1.0): check_version() url = "type=xyz&url=" + get_ee_image_url(image) provider = layer.dataProvider() msg = 'Updating layer with provider %s' % (type(provider).__name__, ) QgsMessageLog.logMessage(msg, 'Earth Engine') provider.setDataSourceUri(url) provider.reloadData() layer.triggerRepaint() layer.reload() iface.mapCanvas().refresh() item = QgsProject.instance().layerTreeRoot().findLayer(layer.id()) if not (shown is None): item.setItemVisibilityChecked(shown)
Example #21
Source File: complexWindow.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def populateComboBox(self): """ Fills the complex combo box with complex classes """ #getting all complex tables self.complexCombo.clear() self.complexCombo.addItem(self.tr("select a complex class")) complexClasses = [] try: complexClasses = self.abstractDb.listComplexClassesFromDatabase() except Exception as e: QMessageBox.critical(self.iface.mainWindow(), self.tr("Critical!"), ':'.join(e.args)) QgsMessageLog.logMessage(e.args[0], 'DSGTools Plugin', Qgis.Critical) self.complexCombo.addItems(complexClasses)
Example #22
Source File: viewServers.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def testServer(self, name): ''' Tests if the server is online ''' abstractDb = self.abstractDbFactory.createDbFactory(DsgEnums.DriverPostGIS) if not abstractDb: QMessageBox.critical(self, self.tr('Critical!'), self.tr('A problem occurred! Check log for details.')) return False (host, port, user, password) = abstractDb.getServerConfiguration(name) abstractDb.connectDatabaseWithParameters(host, port, 'postgres', user, password) try: abstractDb.checkAndOpenDb() abstractDb.closeDatabase() return True except Exception as e: QMessageBox.critical(self, self.tr('Critical!'), self.tr('A problem occurred! Check log for details.')) QgsMessageLog.logMessage(':'.join(e.args), 'DSGTools Plugin', Qgis.Critical) abstractDb.closeDatabase() return False
Example #23
Source File: connectionWidget.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def setCRS(self): """ Sets the CRS information """ try: self.epsg = self.abstractDb.findEPSG() if self.epsg == -1: self.problemOccurred.emit(self.tr('Coordinate Reference System not set or invalid!')) else: self.crs = QgsCoordinateReferenceSystem(self.epsg, QgsCoordinateReferenceSystem.EpsgCrsId) if self.isSpatialite: self.spatialiteCrsEdit.setText(self.crs.description()) self.spatialiteCrsEdit.setReadOnly(True) else: self.postGISCrsEdit.setText(self.crs.description()) self.postGISCrsEdit.setReadOnly(True) except Exception as e: self.problemOccurred.emit(self.tr('A problem occurred! Check log for details.')) QgsMessageLog.logMessage(':'.join(e.args), "DSGTools Plugin", Qgis.Critical)
Example #24
Source File: alter_user_password.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def logInternalError(self, exceptionDict): """ Logs all internal errors into QGIS' log """ msg = '' errorDbList = list(exceptionDict.keys()) if len(errorDbList)> 0: msg += self.tr('\nUsers with error:') msg+= ', '.join(errorDbList) msg+= self.tr('\nError messages for each user were output in qgis log.') for errorDb in errorDbList: QgsMessageLog.logMessage(self.tr('Error for user ')+ errorDb + ': ' +exceptionDict[errorDb], "DSGTools Plugin", Qgis.Critical) return msg
Example #25
Source File: dbProfileManager.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def logInternalError(self, exceptionDict): msg = '' errorDbList = list(exceptionDict.keys()) if len(errorDbList)> 0: msg += self.tr('\Profiles with error:') msg+= ', '.join(errorDbList) msg+= self.tr('\nError messages for each profile were output in qgis log.') for errorDb in errorDbList: QgsMessageLog.logMessage(self.tr('Error for profile ')+ errorDb + ': ' +exceptionDict[errorDb], "DSGTools Plugin", Qgis.Critical) return msg
Example #26
Source File: createBatchFromCsv.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def validatePage(self): #insert validation messages validatedDbParams = self.databaseParameterWidget.validate() if not validatedDbParams: return False validated = self.tabDbSelectorWidget.validate() if not validated: return False parameterDict = self.getParameters() dbDict, errorDict = self.createDatabases(parameterDict) creationMsg = '' if len(list(dbDict.keys())) > 0: creationMsg += self.tr('Database(s) {0} created successfully.').format(', '.join(list(dbDict.keys()))) errorFrameMsg = '' errorMsg = '' if len(list(errorDict.keys())) > 0: frameList = [] errorList = [] for key in list(errorDict.keys()): if self.tr('Invalid inomen parameter!') in errorDict[key]: frameList.append(key) else: errorList.append(key) QgsMessageLog.logMessage(self.tr('Error on {0}: ').format(key)+errorDict[key], "DSGTools Plugin", Qgis.Critical) if len(frameList) > 0: errorFrameMsg += self.tr('Frame was not created on the following databases: {0}').format(', '.join(frameList)) if len(errorList) > 0: errorMsg += self.tr('Some errors occurred while trying to create database(s) {0}').format(', '.join(errorList)) logMsg = '' if errorFrameMsg != '' or errorMsg != '': logMsg += self.tr('Check log for more details.') msg = [i for i in (creationMsg, errorFrameMsg, errorMsg, logMsg) if i != ''] QMessageBox.warning(self, self.tr('Info!'), self.tr('Process finished.')+'\n'+'\n'.join(msg)) return True
Example #27
Source File: createProfileWithProfileManager.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def populateTreeDict(self): """ Makes a tree widget were the user can define profile properties """ try: geomTypeDict = self.abstractDb.getGeomTypeDict() geomDict = self.abstractDb.getGeomDict(geomTypeDict, insertCategory = True) except Exception as e: QMessageBox.critical(self, self.tr('Critical!'), self.tr('A problem occurred! Check log for details.')) QgsMessageLog.logMessage(':'.join(e.args), 'DSGTools Plugin', Qgis.Critical) return version = self.abstractDb.getDatabaseVersion() self.profile = dict() categories = dict() for layerName in list(geomDict.keys()): schema = geomDict[layerName]['schema'] category = geomDict[layerName]['category'] if schema not in list(categories.keys()): categories[schema] = dict() if category not in list(categories[schema].keys()): categories[schema][category] = dict() if layerName not in categories[schema][category]: categories[schema][category][layerName] = dict() categories[schema][category][layerName]['read'] = '0' categories[schema][category][layerName]['write'] = '0' self.profile['database'+'_'+version] = categories
Example #28
Source File: createBatchIncrementing.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def validatePage(self): #insert validation messages validatedDbParams = self.databaseParameterWidget.validate() if not validatedDbParams: return False validated = self.tabDbSelectorWidget.validate() if not validated: return False parameterDict = self.getParameters() dbDict, errorDict = self.createDatabases(parameterDict) creationMsg = '' if len(list(dbDict.keys())) > 0: creationMsg += self.tr('Database(s) {0} created successfully.').format(', '.join(list(dbDict.keys()))) errorMsg = '' if len(list(errorDict.keys())) > 0: frameList = [] errorList = [] for key in list(errorDict.keys()): errorList.append(key) QgsMessageLog.logMessage(self.tr('Error on {0}: ').format(key)+errorDict[key], "DSGTools Plugin", Qgis.Critical) if len(errorList) > 0: errorMsg += self.tr('Some errors occurred while trying to create database(s) {0}').format(', '.join(errorList)) logMsg = '' if errorMsg != '': logMsg += self.tr('Check log for more details.') msg = [i for i in (creationMsg, errorMsg, logMsg) if i != ''] QMessageBox.warning(self, self.tr('Info!'), self.tr('Process finished.')+'\n'+'\n'.join(msg)) return True
Example #29
Source File: genericManagerWidget.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def logInternalError(self, exceptionDict): """ exceptionDict = {configName: {dbName: errorText}} """ msg = '' configList = list(exceptionDict.keys()) if len(configList) > 0: msg += self.tr('\nConfig with error:') + ','.join(configList) msg+= self.tr('\nError messages for each config and database were output in qgis log.') for config in configList: for dbName in list(exceptionDict[config].keys()): if exceptionDict[config][dbName] != dict(): QgsMessageLog.logMessage(self.tr('Error for config ')+ config + ' in database ' +dbName+' : '+exceptionDict[config][dbName], "DSGTools Plugin", Qgis.Critical) return msg
Example #30
Source File: create_profile.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def populateTreeDict(self): """ Makes a tree widget were the user can define profile properties """ self.getDbInfo() tables = [] try: tables = self.abstractDb.getTablesFromDatabase() except Exception as e: QtWidgets.QMessageBox.critical(self, self.tr('Critical!'), self.tr('A problem occurred! Check log for details.')) QgsMessageLog.logMessage(':'.join(e.args), 'DSGTools Plugin', Qgis.Critical) self.profile = dict() categories = dict() for tableName in tables: #proceed only for edgv tables if tableName.split("_")[-1] == "p" or tableName.split("_")[-1] == "l" or tableName.split("_")[-1] == "a" or tableName.split("_")[0] == 'complexos' or tableName.split("_")[0] == 'dominios': layerName = tableName.split('_')[0]+'.'+'_'.join(tableName.split('_')[1::]) split = tableName.split('_') if len(split) < 2: continue schema = split[0] category = split[1] if schema not in list(categories.keys()): categories[schema] = dict() if category not in list(categories[schema].keys()): categories[schema][category] = dict() if layerName not in categories[schema][category]: categories[schema][category][layerName] = dict() categories[schema][category][layerName]['read'] = '0' categories[schema][category][layerName]['write'] = '0' self.profile['database'+'_'+self.versionCombo.currentText()] = categories