当前位置: 首页>>代码示例>>Python>>正文


Python QgsMessageLog.logMessage方法代码示例

本文整理汇总了Python中qgis.core.QgsMessageLog.logMessage方法的典型用法代码示例。如果您正苦于以下问题:Python QgsMessageLog.logMessage方法的具体用法?Python QgsMessageLog.logMessage怎么用?Python QgsMessageLog.logMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qgis.core.QgsMessageLog的用法示例。


在下文中一共展示了QgsMessageLog.logMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: editConnectionDialog

# 需要导入模块: from qgis.core import QgsMessageLog [as 别名]
# 或者: from qgis.core.QgsMessageLog import logMessage [as 别名]
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() 
开发者ID:gkudos,项目名称:qgis-cartodb,代码行数:19,代码来源:ConnectionManager.py

示例2: _updateGeometries

# 需要导入模块: from qgis.core import QgsMessageLog [as 别名]
# 或者: from qgis.core.QgsMessageLog import logMessage [as 别名]
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) 
开发者ID:gkudos,项目名称:qgis-cartodb,代码行数:22,代码来源:CartoDBLayer.py

示例3: _deleteFeatures

# 需要导入模块: from qgis.core import QgsMessageLog [as 别名]
# 或者: from qgis.core.QgsMessageLog import logMessage [as 别名]
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 = [] 
开发者ID:gkudos,项目名称:qgis-cartodb,代码行数:20,代码来源:CartoDBLayer.py

示例4: addSQL

# 需要导入模块: from qgis.core import QgsMessageLog [as 别名]
# 或者: from qgis.core.QgsMessageLog import logMessage [as 别名]
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) 
开发者ID:gkudos,项目名称:qgis-cartodb,代码行数:18,代码来源:CartoDBPlugin.py

示例5: pushFeedback

# 需要导入模块: from qgis.core import QgsMessageLog [as 别名]
# 或者: from qgis.core.QgsMessageLog import logMessage [as 别名]
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*"=")
        """ 
开发者ID:nkarasiak,项目名称:dzetsaka,代码行数:23,代码来源:mainfunction.py

示例6: log

# 需要导入模块: from qgis.core import QgsMessageLog [as 别名]
# 或者: from qgis.core.QgsMessageLog import logMessage [as 别名]
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) 
开发者ID:GIScience,项目名称:orstools-qgis-plugin,代码行数:22,代码来源:logger.py

示例7: __init__

# 需要导入模块: from qgis.core import QgsMessageLog [as 别名]
# 或者: from qgis.core.QgsMessageLog import logMessage [as 别名]
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) 
开发者ID:opengisch,项目名称:qfieldsync,代码行数:26,代码来源:exceptions.py

示例8: update_ee_image_layer

# 需要导入模块: from qgis.core import QgsMessageLog [as 别名]
# 或者: from qgis.core.QgsMessageLog import logMessage [as 别名]
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) 
开发者ID:gee-community,项目名称:qgis-earthengine-plugin,代码行数:20,代码来源:utils.py

示例9: testServer

# 需要导入模块: from qgis.core import QgsMessageLog [as 别名]
# 或者: from qgis.core.QgsMessageLog import logMessage [as 别名]
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 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:21,代码来源:viewServers.py

示例10: setCRS

# 需要导入模块: from qgis.core import QgsMessageLog [as 别名]
# 或者: from qgis.core.QgsMessageLog import logMessage [as 别名]
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) 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:21,代码来源:connectionWidget.py

示例11: getDbsFromServer

# 需要导入模块: from qgis.core import QgsMessageLog [as 别名]
# 或者: from qgis.core.QgsMessageLog import logMessage [as 别名]
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) 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:26,代码来源:exploreServerWidget.py

示例12: loadDatabase

# 需要导入模块: from qgis.core import QgsMessageLog [as 别名]
# 或者: from qgis.core.QgsMessageLog import logMessage [as 别名]
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) 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:20,代码来源:databaseFileLineEdit.py

示例13: loadDatabase

# 需要导入模块: from qgis.core import QgsMessageLog [as 别名]
# 或者: from qgis.core.QgsMessageLog import logMessage [as 别名]
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) 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:22,代码来源:connectionComboBox.py

示例14: loadDatabase

# 需要导入模块: from qgis.core import QgsMessageLog [as 别名]
# 或者: from qgis.core.QgsMessageLog import logMessage [as 别名]
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) 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:19,代码来源:newConnectionLineEdit.py

示例15: loadDatabase

# 需要导入模块: from qgis.core import QgsMessageLog [as 别名]
# 或者: from qgis.core.QgsMessageLog import logMessage [as 别名]
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) 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:20,代码来源:newDatabaseLineEdit.py


注:本文中的qgis.core.QgsMessageLog.logMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。