示例#1
0
 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)
示例#2
0
    def createInstance(self, config=None):
        try:
            products = self.get_products_and_measurements()
        except SQLAlchemyError:
            msg = 'Unable to connect to a running Data Cube instance'
            QgsLogger().warning(msg)
            products = {msg: {'measurements': {}}}

        return type(self)(products)
示例#3
0
    def __refreshMapOL(self):
        # catch Exception where lat/long exceed limit of the loaded layer
        # the Exception name is unknown
        latlon = None
        try:
            latlon = self.__getCenterLongLat2OL()
        except Exception as e:
            QgsLogger().warning(e.args[0])

        if latlon:
            action = "map.setCenter(new OpenLayers.LonLat(%f, %f));" % (latlon)
            self.webViewMap.page().mainFrame().evaluateJavaScript(action)
            action = "map.zoomToScale(%f);" % self.__canvas.scale()
            self.webViewMap.page().mainFrame().evaluateJavaScript(action)
            self.webViewMap.page().mainFrame().evaluateJavaScript(
                "oloMarker.changeMarker();")