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


Python Qgis.Critical方法代码示例

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


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

示例1: log

# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Critical [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

示例2: __init__

# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Critical [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

示例3: testServer

# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Critical [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

示例4: getDatabasesFromServer

# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Critical [as 别名]
def getDatabasesFromServer(self):
        """
        Gets databases from server
        """  
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        try:
            if self.serverWidget.abstractDb:
                dbList = self.serverWidget.abstractDb.getEDGVDbsFromServer(parentWidget = self)
                dbList.sort()
                self.comboBoxPostgis.clear()
                self.comboBoxPostgis.addItem(self.tr('Select Database'))
                for db, version in dbList:
                    self.comboBoxPostgis.addItem(db)
                
            else:
                self.setInitialState()
                QApplication.restoreOverrideCursor()
                return
        except Exception as e:
            QApplication.restoreOverrideCursor()
            QMessageBox.critical(self, self.tr('Critical!'), ':'.join(e.args))
            self.setInitialState()
        QApplication.restoreOverrideCursor() 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:25,代码来源:connectionWidget.py

示例5: getDbsFromServer

# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Critical [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

示例6: loadDatabase

# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Critical [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

示例7: setServerDb

# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Critical [as 别名]
def setServerDb(self, serverAbstractDb):
        self.serverAbstractDb = serverAbstractDb
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        try:
            if self.serverAbstractDb:
                dbList = self.serverAbstractDb.getEDGVDbsFromServer(parentWidget = self.parent, getDatabaseVersions = False)
                dbList.sort()
                self.clear()
                self.connectionSelectorComboBox.addItem(self.tr('Select Database'))
                self.addItems(dbList)
            else:
                self.clear()
                self.abstractDb = None
                QApplication.restoreOverrideCursor()
                return
        except Exception as e:
            QApplication.restoreOverrideCursor()
            QMessageBox.critical(self, self.tr('Critical!'), ':'.join(e.args))
        QApplication.restoreOverrideCursor() 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:21,代码来源:connectionComboBox.py

示例8: loadDatabase

# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Critical [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

示例9: loadDatabase

# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Critical [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

示例10: loadDatabase

# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Critical [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

示例11: validate

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

示例12: on_removeUserButton_clicked

# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Critical [as 别名]
def on_removeUserButton_clicked(self):
        selectedUsers = self.serverUserTable.selectedItems()
        if not self.abstractDb:
            QMessageBox.critical(self, self.tr('Critical!'), self.tr('First select a database!'))
            return
        if len(selectedUsers) == 0:
            QMessageBox.critical(self, self.tr('Critical!'), self.tr('First select a user to remove!'))
            return
        selectedUserNames = [i.text(0) for i in selectedUsers]
        if QMessageBox.question(self, self.tr('Question'), self.tr('Do you really want to remove users: ')+', '.join(selectedUserNames), QMessageBox.Ok|QMessageBox.Cancel) == QMessageBox.Cancel:
            return
        exceptionDict = dict()
        successList = []
        for user in selectedUserNames:
            try:
                self.abstractDb.reassignAndDropUser(user)
                successList.append(user)
            except Exception as e:
                exceptionDict[user] =  ':'.join(e.args)
        header = self.tr('Drop user(s) operation complete!\n')
        self.outputMessage(header, successList, exceptionDict)
        self.populateUsers() 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:24,代码来源:manageServerUsers.py

示例13: flipSelectedLines

# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Critical [as 别名]
def flipSelectedLines(self):
        """
        Method for flipping all selected lines. Used for button callback.
        """        
        # get all selected features and remove all features that are not lines
        selectedFeatures = self.getAllSelectedLines()
        pop = 0
        for idx, item in enumerate(selectedFeatures):
            if item[2] != 1:
                selectedFeatures.pop(idx-pop)
                pop += 1
        if not selectedFeatures:
            logMsg = self.getLogMessage(None, None)
            self.iface.messageBar().pushMessage(self.tr('Error'), logMsg, level=Qgis.Critical, duration=3)
            # QMessageBox.critical(self, self.tr('Critical!'), logMsg)
            QgsMessageLog.logMessage(logMsg, "DSGTools Plugin", Qgis.Critical)
            return
        # call the method for flipping features from geometry module
        flippedLines, failedLines = self.DsgGeometryHandler.flipFeatureList(featureList=selectedFeatures, debugging=True)
        logMsg = self.getLogMessage(flippedLines, failedLines)
        self.iface.messageBar().pushMessage(self.tr('Success'), logMsg, level=Qgis.Info, duration=3)
        QgsMessageLog.logMessage(logMsg, "DSGTools Plugin", Qgis.Info) 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:24,代码来源:flipLineTool.py

示例14: log_error

# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Critical [as 别名]
def log_error(cls, msg):
        QgsMessageLog.logMessage(msg, tag="Raster Vision", level=Qgis.Critical) 
开发者ID:azavea,项目名称:raster-vision-qgis,代码行数:4,代码来源:log.py

示例15: setError

# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Critical [as 别名]
def setError(msg, trace=None):
    iface.messageBar().pushMessage("Geoserver", msg, level=Qgis.Warning, duration=10)
    if trace is not None:
        QgsMessageLog.logMessage("{}:{}".format(msg, trace), level=Qgis.Critical) 
开发者ID:planetfederal,项目名称:qgis-geoserver-plugin,代码行数:6,代码来源:__init__.py


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