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


Python QgsLogger.warning方法代码示例

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


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

示例1: testLogger

# 需要导入模块: from qgis.core import QgsLogger [as 别名]
# 或者: from qgis.core.QgsLogger import warning [as 别名]
 def testLogger(self):
     (myFileHandle, myFilename) = tempfile.mkstemp()
     try:
         myFile = os.fdopen(myFileHandle, "w")
         myFile.write("QGIS Logger Unit Test\n")
         myFile.close()
         os.environ['QGIS_DEBUG'] = '2'
         os.environ['QGIS_LOG_FILE'] = myFilename
         myLogger = QgsLogger()
         myLogger.debug('This is a debug')
         myLogger.warning('This is a warning')
         myLogger.critical('This is critical')
         #myLogger.fatal('Aaaargh...fatal');  #kills QGIS not testable
         myFile = open(myFilename, 'rt')
         myText = myFile.readlines()
         myFile.close()
         myExpectedText = ['QGIS Logger Unit Test\n',
                           'This is a debug\n',
                           'This is a warning\n',
                           'This is critical\n']
         myMessage = ('Expected:\n---\n%s\n---\nGot:\n---\n%s\n---\n' %
                            (myExpectedText, myText))
         self.assertEquals(myText, myExpectedText, myMessage)
     finally:
         pass
         os.remove(myFilename)
开发者ID:AaronGaim,项目名称:QGIS,代码行数:28,代码来源:test_qgslogger.py

示例2: testLogger

# 需要导入模块: from qgis.core import QgsLogger [as 别名]
# 或者: from qgis.core.QgsLogger import warning [as 别名]
 def testLogger(self):
     try:
         myFile = os.fdopen(myFileHandle, "w")
         myFile.write("QGIS Logger Unit Test\n")
         myFile.close()
         myLogger = QgsLogger()
         myLogger.debug("This is a debug")
         myLogger.warning("This is a warning")
         myLogger.critical("This is critical")
         # myLogger.fatal('Aaaargh...fatal');  #kills QGIS not testable
         myFile = open(myFilename, "rt")
         myText = myFile.readlines()
         myFile.close()
         myExpectedText = [
             "QGIS Logger Unit Test\n",
             "This is a debug\n",
             "This is a warning\n",
             "This is critical\n",
         ]
         myMessage = "Expected:\n---\n%s\n---\nGot:\n---\n%s\n---\n" % (myExpectedText, myText)
         self.assertEqual(myText, myExpectedText, myMessage)
     finally:
         pass
         os.remove(myFilename)
开发者ID:liminlu0314,项目名称:QGIS,代码行数:26,代码来源:test_qgslogger.py

示例3: getSupportedVectors

# 需要导入模块: from qgis.core import QgsLogger [as 别名]
# 或者: from qgis.core.QgsLogger import warning [as 别名]
    def getSupportedVectors(self):
        if self.supportedVectors is not None:
            return self.supportedVectors

        # first get the OGR driver manager
        QgsApplication.registerOgrDrivers()

        self.supportedVectors = dict()

        # for each loaded OGR driver
        for i in range(ogr.GetDriverCount()):
            driver = ogr.GetDriver(i)

            if driver is None:
                QgsLogger.warning("unable to get driver " + str(i))
                continue

            driverName = driver.GetName()
            longName = ''
            glob = []

            if driverName.startswith("AVCBin"):
                pass  # myDirectoryDrivers += "Arc/Info Binary Coverage,AVCBin"
            elif driverName.startswith("AVCE00"):
                longName = "Arc/Info ASCII Coverage"
                glob.append("*.e00")
            elif driverName.startswith("BNA"):
                longName = "Atlas BNA"
                glob.append("*.bna")
            elif driverName.startswith("CSV"):
                longName = "Comma Separated Value"
                glob.append("*.csv")
            elif driverName.startswith("DODS"):
                pass  # myProtocolDrivers += "DODS/OPeNDAP,DODS"
            elif driverName.startswith("PGeo"):
                pass  # myDatabaseDrivers += "ESRI Personal GeoDatabase,PGeo"

                # on Windows add a pair to the dict for this driver
                if platform.system() == "Windows":
                    longName = "ESRI Personal GeoDatabase"
                    glob.append("*.mdb")
            elif driverName.startswith("SDE"):
                pass  # myDatabaseDrivers += "ESRI ArcSDE,SDE"
            elif driverName.startswith("ESRI"):
                longName = "ESRI Shapefiles"
                glob.append("*.shp")
            elif driverName.startswith("FMEObjects Gateway"):
                longName = "FMEObjects Gateway"
                glob.append("*.fdd")
            elif driverName.startswith("GeoJSON"):
                pass  # myProtocolDrivers += "GeoJSON,GeoJSON"
                longName = "GeoJSON"
                glob.append("*.geojson")
            elif driverName.startswith("GeoRSS"):
                longName = "GeoRSS"
                glob.append("*.xml")
            elif driverName.startswith("GML"):
                longName = "Geography Markup Language"
                glob.append("*.gml")
            elif driverName.startswith("GMT"):
                longName = "GMT"
                glob.append("*.gmt")
            elif driverName.startswith("GPX"):
                longName = "GPX"
                glob.append("*.gpx")
            elif driverName.startswith("GRASS"):
                pass  # myDirectoryDrivers += "Grass Vector,GRASS"
            elif driverName.startswith("IDB"):
                pass  # myDatabaseDrivers += "Informix DataBlade,IDB"
            elif driverName.startswith("Interlis 1"):
                longName = "INTERLIS 1"
                glob.append("*.itf")
                glob.append("*.xml")
                glob.append("*.ili")
            elif driverName.startswith("Interlis 2"):
                longName = "INTERLIS 2"
                glob.append("*.itf")
                glob.append("*.xml")
                glob.append("*.ili")
            elif driverName.startswith("INGRES"):
                pass  # myDatabaseDrivers += "INGRES,INGRES"
            elif driverName.startswith("KML"):
                longName = "KML"
                glob.append("*.kml")
            elif driverName.startswith("MapInfo File"):
                longName = "Mapinfo File"
                glob.append("*.mif")
                glob.append("*.tab")
            elif driverName.startswith("DGN"):
                longName = "Microstation DGN"
                glob.append("*.dgn")
            elif driverName.startswith("MySQL"):
                pass  # myDatabaseDrivers += "MySQL,MySQL"
            elif driverName.startswith("OCI"):
                pass  # myDatabaseDrivers += "Oracle Spatial,OCI"
            elif driverName.startswith("ODBC"):
                pass  # myDatabaseDrivers += "ODBC,ODBC"
            elif driverName.startswith("OGDI"):
                pass  # myDatabaseDrivers += "OGDI Vectors,OGDI"
            elif driverName.startswith("PostgreSQL"):
#.........这里部分代码省略.........
开发者ID:liminlu0314,项目名称:QGIS,代码行数:103,代码来源:GdalTools_utils.py

示例4: getSupportedRasters

# 需要导入模块: from qgis.core import QgsLogger [as 别名]
# 或者: from qgis.core.QgsLogger import warning [as 别名]
    def getSupportedRasters(self):
        if self.supportedRasters is not None:
            return self.supportedRasters

        # first get the GDAL driver manager
        if gdal.GetDriverCount() == 0:
            gdal.AllRegister()

        self.supportedRasters = dict()
        jp2Driver = None

        # for each loaded GDAL driver
        for i in range(gdal.GetDriverCount()):
            driver = gdal.GetDriver(i)

            if driver is None:
                QgsLogger.warning("unable to get driver " + str(i))
                continue

            # now we need to see if the driver is for something currently
            # supported; if not, we give it a miss for the next driver

            longName = string.strip(re.sub('\(.*$', '', driver.LongName))
            shortName = string.strip(re.sub('\(.*$', '', driver.ShortName))
            extensions = ''

            description = driver.GetDescription()
            glob = []

            metadata = driver.GetMetadata()
            if gdal.DMD_EXTENSION in metadata:
                extensions = str(metadata[gdal.DMD_EXTENSION])

            if longName != '':
                if extensions != '':
                    # XXX add check for SDTS; in that case we want (*CATD.DDF)

                    #TODO fix and test
                    #glob.append( QString("*." + extensions.replace("/", " *.")).split(" "))
                    glob.append(string.split("*." + string.replace(extensions, "/", " *."), sep=(" ")))

                    # Add only the first JP2 driver found to the filter list (it's the one GDAL uses)
                    if description == "JPEG2000" or description.startswith("JP2"):  # JP2ECW, JP2KAK, JP2MrSID
                        if jp2Driver is not None:
                            continue               # skip if already found a JP2 driver
                        jp2Driver = driver   # first JP2 driver found
                        glob.append("*.j2k")           # add alternate extension
                    elif description == "GTiff":
                        glob.append("*.tiff")
                    elif description == "JPEG":
                        glob.append("*.jpeg")
                else:
                    # USGS DEMs use "*.dem"
                    if description.startswith("USGSDEM"):
                        glob.append("*.dem")
                    elif description.startswith("DTED"):
                        # DTED use "*.dt0"
                        glob.append("*.dt0")
                    elif description.startswith("MrSID"):
                        # MrSID use "*.sid"
                        glob.append("*.sid")
                    else:
                        continue

                self.supportedRasters[longName] = {'EXTENSIONS': glob, 'LONGNAME': longName, 'SHORTNAME': shortName, 'DESCRIPTION': description}

        return self.supportedRasters
开发者ID:liminlu0314,项目名称:QGIS,代码行数:69,代码来源:GdalTools_utils.py


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