mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-22 00:14:55 -05:00
Fix subprocess unclosed file
This commit is contained in:
parent
5ef16bf659
commit
c3ad30da34
@ -254,7 +254,7 @@ class Grass7Utils(object):
|
|||||||
loglines.append(Grass7Utils.tr('GRASS GIS 7 execution console output'))
|
loglines.append(Grass7Utils.tr('GRASS GIS 7 execution console output'))
|
||||||
grassOutDone = False
|
grassOutDone = False
|
||||||
command, grassenv = Grass7Utils.prepareGrass7Execution(commands)
|
command, grassenv = Grass7Utils.prepareGrass7Execution(commands)
|
||||||
proc = subprocess.Popen(
|
with subprocess.Popen(
|
||||||
command,
|
command,
|
||||||
shell=True,
|
shell=True,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
@ -262,18 +262,18 @@ class Grass7Utils(object):
|
|||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
universal_newlines=True,
|
universal_newlines=True,
|
||||||
env=grassenv
|
env=grassenv
|
||||||
).stdout
|
) as proc:
|
||||||
for line in iter(proc.readline, ''):
|
for line in iter(proc.stdout.readline, ''):
|
||||||
if 'GRASS_INFO_PERCENT' in line:
|
if 'GRASS_INFO_PERCENT' in line:
|
||||||
try:
|
try:
|
||||||
progress.setPercentage(int(line[len('GRASS_INFO_PERCENT') + 2:]))
|
progress.setPercentage(int(line[len('GRASS_INFO_PERCENT') + 2:]))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if 'r.out' in line or 'v.out' in line:
|
if 'r.out' in line or 'v.out' in line:
|
||||||
grassOutDone = True
|
grassOutDone = True
|
||||||
loglines.append(line)
|
loglines.append(line)
|
||||||
progress.setConsoleInfo(line)
|
progress.setConsoleInfo(line)
|
||||||
|
|
||||||
# Some GRASS scripts, like r.mapcalculator or r.fillnulls, call
|
# Some GRASS scripts, like r.mapcalculator or r.fillnulls, call
|
||||||
# other GRASS scripts during execution. This may override any
|
# other GRASS scripts during execution. This may override any
|
||||||
@ -283,7 +283,7 @@ class Grass7Utils(object):
|
|||||||
|
|
||||||
if not grassOutDone and outputCommands:
|
if not grassOutDone and outputCommands:
|
||||||
command, grassenv = Grass7Utils.prepareGrass7Execution(outputCommands)
|
command, grassenv = Grass7Utils.prepareGrass7Execution(outputCommands)
|
||||||
proc = subprocess.Popen(
|
with subprocess.Popen(
|
||||||
command,
|
command,
|
||||||
shell=True,
|
shell=True,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
@ -291,17 +291,17 @@ class Grass7Utils(object):
|
|||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
universal_newlines=True,
|
universal_newlines=True,
|
||||||
env=grassenv
|
env=grassenv
|
||||||
).stdout
|
) as proc:
|
||||||
for line in iter(proc.readline, ''):
|
for line in iter(proc.stdout.readline, ''):
|
||||||
if 'GRASS_INFO_PERCENT' in line:
|
if 'GRASS_INFO_PERCENT' in line:
|
||||||
try:
|
try:
|
||||||
progress.setPercentage(int(
|
progress.setPercentage(int(
|
||||||
line[len('GRASS_INFO_PERCENT') + 2:]))
|
line[len('GRASS_INFO_PERCENT') + 2:]))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
loglines.append(line)
|
loglines.append(line)
|
||||||
progress.setConsoleInfo(line)
|
progress.setConsoleInfo(line)
|
||||||
|
|
||||||
if ProcessingConfig.getSetting(Grass7Utils.GRASS_LOG_CONSOLE):
|
if ProcessingConfig.getSetting(Grass7Utils.GRASS_LOG_CONSOLE):
|
||||||
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
|
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user