Open biglimp opened 4 years ago
Hi Fredrik, CDSAPI and supy both use the logging
module for porting messages to log files/consoles. I think we just need to redirect the outlet from the logging
-related functions to the QGIS ones.
Do you have an example for the feedback stuff?
e.g.: feedback.setProgressText("Some string output")
The feedback is inherited from the class below (I think) https://qgis.org/pyqgis/3.4/core/QgsProcessingFeedback.html?highlight=feedback#module-QgsProcessingFeedback
If you just have a look at line 150 in copernicusera5_algorithm.py...
Maybe we can use something like this (found this in another QGIS plugin). There is function called feedback.pushConsoleInfo():
loglines = []
with subprocess.Popen(fused_command,
shell=True,
stdout=subprocess.PIPE,
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=True) as proc:
try:
for line in iter(proc.stdout.readline, ''):
feedback.pushConsoleInfo(line)
loglines.append(line)
except:
pass
This looks nice - in fact, supy does produce a SuPy.log
file, which seems a good fit to this approach.
Ting, I have ported the ERA5 downloader to the Processing Toolbox. It works but it would have been nice to add the log output from CDSAPI and maybe also SuPy to the Log window in the toolbox. Do you have any idea how to get output from the python console (in QGIS) to another log? The QgsProcessing class comes with a feedback capabiliy that can be used to put out text to the log window. See e.g. line 150 in copernicusera5_algorithm.py