Skip to main content
Post Reopened by PolyGeo
edited tags
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

QGIS get Getting log message from QGIS processing framework?

I run Python processing algorithms externally, and I want to get the log output I see when I run it from the QGIS 3 GUI at the log tab as shown in the screenshot:   

enter image description here I

I want to get the full grey log output when Result is returned only. 

How do I do that?

An example follows:

import os
import sys
import gdal
gdal.UseExceptions()  # Allow GDAL to throw Python Exceptions

from qgis.core import (
    QgsApplication,
    QgsProcessingFeedback,
    QgsMessageLog)

from qgis.analysis import QgsNativeAlgorithms

QgsApplication.setPrefixPath(os.path.join("C:", os.sep, "OSGeo4W64", "apps", "qgis"), True)
qgs = QgsApplication([], False)
qgs.initQgis()

sys.path.append(os.path.join("C:", os.sep, "OSGeo4W64", "apps", "qgis", "python", "plugins"))
import processing
from processing.core.Processing import Processing

Processing.initialize()
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())


def pca(input_raster_list):

    params = {
                'input': input_raster_list,
                'rescale': [0,0],
                'percent': 99,
                '-n': True,
                '-f': False,
                'output': 'C:\\Users\\...',
                'GRASS_REGION_PARAMETER': None,
                'GRASS_REGION_CELLSIZE_PARAMETER': 0
                }
    feedback = QgsProcessingFeedback()
    res = processing.run("grass7:i.pca", params, feedback=feedback)
    print(res)

    return

QGIS get log message from processing framework

I run Python processing algorithms externally, and I want to get the log output I see when I run it from the QGIS 3 GUI at the log tab as shown in the screenshot:  enter image description here I want to get the full grey log output when Result is returned only. How do I do that?

An example follows:

import os
import sys
import gdal
gdal.UseExceptions()  # Allow GDAL to throw Python Exceptions

from qgis.core import (
    QgsApplication,
    QgsProcessingFeedback,
    QgsMessageLog)

from qgis.analysis import QgsNativeAlgorithms

QgsApplication.setPrefixPath(os.path.join("C:", os.sep, "OSGeo4W64", "apps", "qgis"), True)
qgs = QgsApplication([], False)
qgs.initQgis()

sys.path.append(os.path.join("C:", os.sep, "OSGeo4W64", "apps", "qgis", "python", "plugins"))
import processing
from processing.core.Processing import Processing

Processing.initialize()
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())


def pca(input_raster_list):

    params = {
                'input': input_raster_list,
                'rescale': [0,0],
                'percent': 99,
                '-n': True,
                '-f': False,
                'output': 'C:\\Users\\...',
                'GRASS_REGION_PARAMETER': None,
                'GRASS_REGION_CELLSIZE_PARAMETER': 0
                }
    feedback = QgsProcessingFeedback()
    res = processing.run("grass7:i.pca", params, feedback=feedback)
    print(res)

    return

Getting log message from QGIS processing framework?

I run Python processing algorithms externally, and I want to get the log output I see when I run it from the QGIS 3 GUI at the log tab as shown in the screenshot: 

enter image description here

I want to get the full grey log output when Result is returned only. 

How do I do that?

An example follows:

import os
import sys
import gdal
gdal.UseExceptions()  # Allow GDAL to throw Python Exceptions

from qgis.core import (
    QgsApplication,
    QgsProcessingFeedback,
    QgsMessageLog)

from qgis.analysis import QgsNativeAlgorithms

QgsApplication.setPrefixPath(os.path.join("C:", os.sep, "OSGeo4W64", "apps", "qgis"), True)
qgs = QgsApplication([], False)
qgs.initQgis()

sys.path.append(os.path.join("C:", os.sep, "OSGeo4W64", "apps", "qgis", "python", "plugins"))
import processing
from processing.core.Processing import Processing

Processing.initialize()
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())


def pca(input_raster_list):

    params = {
                'input': input_raster_list,
                'rescale': [0,0],
                'percent': 99,
                '-n': True,
                '-f': False,
                'output': 'C:\\Users\\...',
                'GRASS_REGION_PARAMETER': None,
                'GRASS_REGION_CELLSIZE_PARAMETER': 0
                }
    feedback = QgsProcessingFeedback()
    res = processing.run("grass7:i.pca", params, feedback=feedback)
    print(res)

    return
added 1559 characters in body; edited tags
Source Link
ODstuck
  • 661
  • 6
  • 18

I run Python processing algorithms externally, and I want to get the log output I see when I run it from the QGIS 3 GUI at the log tab as shown in the screenshot: enter image description here I want to get the full grey log output when Result is returned only. How do I do that?

An example follows:

import os
import sys
import gdal
gdal.UseExceptions()  # Allow GDAL to throw Python Exceptions

from qgis.core import (
    QgsApplication,
    QgsProcessingFeedback,
    QgsMessageLog)

from qgis.analysis import QgsNativeAlgorithms

QgsApplication.setPrefixPath(os.path.join("C:", os.sep, "OSGeo4W64", "apps", "qgis"), True)
qgs = QgsApplication([], False)
qgs.initQgis()

sys.path.append(os.path.join("C:", os.sep, "OSGeo4W64", "apps", "qgis", "python", "plugins"))
import processing
from processing.core.Processing import Processing

Processing.initialize()
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())


def pca(input_raster_list):

    params = {
                'input': input_raster_list,
                'rescale': [0,0],
                'percent': 99,
                '-n': True,
                '-f': False,
                'output': 'C:\\Users\\...',
                'GRASS_REGION_PARAMETER': None,
                'GRASS_REGION_CELLSIZE_PARAMETER': 0
                }
    feedback = QgsProcessingFeedback()
    res = processing.run("grass7:i.pca", params, feedback=feedback)
    print(res)

    return

I run Python processing algorithms externally, and I want to get the log output I see when I run it from the QGIS 3 GUI at the log tab. How do I do that?

I run Python processing algorithms externally, and I want to get the log output I see when I run it from the QGIS 3 GUI at the log tab as shown in the screenshot: enter image description here I want to get the full grey log output when Result is returned only. How do I do that?

An example follows:

import os
import sys
import gdal
gdal.UseExceptions()  # Allow GDAL to throw Python Exceptions

from qgis.core import (
    QgsApplication,
    QgsProcessingFeedback,
    QgsMessageLog)

from qgis.analysis import QgsNativeAlgorithms

QgsApplication.setPrefixPath(os.path.join("C:", os.sep, "OSGeo4W64", "apps", "qgis"), True)
qgs = QgsApplication([], False)
qgs.initQgis()

sys.path.append(os.path.join("C:", os.sep, "OSGeo4W64", "apps", "qgis", "python", "plugins"))
import processing
from processing.core.Processing import Processing

Processing.initialize()
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())


def pca(input_raster_list):

    params = {
                'input': input_raster_list,
                'rescale': [0,0],
                'percent': 99,
                '-n': True,
                '-f': False,
                'output': 'C:\\Users\\...',
                'GRASS_REGION_PARAMETER': None,
                'GRASS_REGION_CELLSIZE_PARAMETER': 0
                }
    feedback = QgsProcessingFeedback()
    res = processing.run("grass7:i.pca", params, feedback=feedback)
    print(res)

    return
Post Closed as "Not suitable for this site" by underdark
edited title
Link
ODstuck
  • 661
  • 6
  • 18

PyQGIS QGIS get log message from processing framework

Source Link
ODstuck
  • 661
  • 6
  • 18
Loading