當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。