Skip to content

Commit

Permalink
[processing] Catch the gdal process console progress report output
Browse files Browse the repository at this point in the history
and show algorithm progress bars when running GDAL algorithms
  • Loading branch information
nyalldawson committed Jan 8, 2021
1 parent 54ec5ac commit b14dc49
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions python/plugins/processing/algs/gdal/GdalUtils.py
Expand Up @@ -105,13 +105,25 @@ def runGdal(commands, feedback=None):

def on_stdout(ba):
val = ba.data().decode('UTF-8')
# catch progress reports
if val == '100 - done.':
on_stdout.progress = 100
feedback.setProgress(on_stdout.progress)
elif val in ('0', '10', '20', '30', '40', '50', '60', '70', '80', '90'):
on_stdout.progress = int(val)
feedback.setProgress(on_stdout.progress)
elif val == '.':
on_stdout.progress += 2.5
feedback.setProgress(on_stdout.progress)

on_stdout.buffer += val
if on_stdout.buffer.endswith('\n') or on_stdout.buffer.endswith('\r'):
# flush buffer
feedback.pushConsoleInfo(on_stdout.buffer.rstrip())
loglines.append(on_stdout.buffer.rstrip())
on_stdout.buffer = ''

on_stdout.progress = 0
on_stdout.buffer = ''

def on_stderr(ba):
Expand Down

0 comments on commit b14dc49

Please sign in to comment.