Skip to content

Commit

Permalink
[processing] Use subprocess.DEVNULL instead of open(os.devnull)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 7, 2016
1 parent 6a99017 commit 0484769
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/GdalUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def runGdal(commands, progress=None):
fused_command,
shell=True,
stdout=subprocess.PIPE,
stdin=open(os.devnull),
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=True,
).stdout
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/grass/GrassUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def executeGrass(commands, progress, outputCommands=None):
command,
shell=True,
stdout=subprocess.PIPE,
stdin=open(os.devnull),
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=True,
env=grassenv
Expand Down Expand Up @@ -307,7 +307,7 @@ def executeGrass(commands, progress, outputCommands=None):
command,
shell=True,
stdout=subprocess.PIPE,
stdin=open(os.devnull),
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=True,
env=grassenv
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/grass7/Grass7Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def executeGrass7(commands, progress, outputCommands=None):
command,
shell=True,
stdout=subprocess.PIPE,
stdin=open(os.devnull),
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=True,
env=grassenv
Expand Down Expand Up @@ -287,7 +287,7 @@ def executeGrass7(commands, progress, outputCommands=None):
command,
shell=True,
stdout=subprocess.PIPE,
stdin=open(os.devnull),
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=True,
env=grassenv
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/lidar/fusion/FusionUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def runFusion(commands, progress):
commands,
shell=True,
stdout=subprocess.PIPE,
stdin=open(os.devnull),
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=False,
).stdout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def runLAStools(commands, progress):
loglines.append(QCoreApplication.translate("LAStoolsUtils", "LAStools command line"))
loglines.append(commandline)
loglines.append(QCoreApplication.translate("LAStoolsUtils", "LAStools console output"))
proc = subprocess.Popen(commandline, shell=True, stdout=subprocess.PIPE, stdin=open(os.devnull),
proc = subprocess.Popen(commandline, shell=True, stdout=subprocess.PIPE, stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT, universal_newlines=False).stdout
for line in iter(proc.readline, ""):
loglines.append(line)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/otb/OTBUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def executeOtb(commands, progress, addToLog=True):
loglines.append(tr("OTB execution console output"))
os.putenv('ITK_AUTOLOAD_PATH', otbLibPath())
fused_command = ''.join(['"%s" ' % re.sub(r'^"|"$', '', c) for c in commands])
proc = subprocess.Popen(fused_command, shell=True, stdout=subprocess.PIPE, stdin=open(os.devnull), stderr=subprocess.STDOUT, universal_newlines=True).stdout
proc = subprocess.Popen(fused_command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.DEVNULL, stderr=subprocess.STDOUT, universal_newlines=True).stdout
if isMac(): # This trick avoids having an uninterrupted system call exception if OTB is not installed
time.sleep(1)
for line in iter(proc.readline, ""):
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/r/RUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def executeRAlgorithm(alg, progress):
command,
shell=True,
stdout=subprocess.PIPE,
stdin=open(os.devnull),
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=True,
)
Expand Down Expand Up @@ -213,7 +213,7 @@ def checkRIsInstalled(ignoreRegistrySettings=False):
command,
shell=True,
stdout=subprocess.PIPE,
stdin=open(os.devnull),
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=True,
).stdout
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/saga/SagaDescriptionCreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def createLibraryFiles(self):
command,
shell=True,
stdout=f2,
stdin=open(os.devnull),
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=True,
)
Expand Down Expand Up @@ -81,7 +81,7 @@ def createDescriptionFiles(self):
command,
shell=True,
stdout=f,
stdin=open(os.devnull),
stdin=subprocess.DEVNULL,
stderr=f,
universal_newlines=True,
)
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/saga/SagaUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def getSagaInstalledVersion(runSaga=False):
commands,
shell=True,
stdout=subprocess.PIPE,
stdin=open(os.devnull),
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=True,
).stdout
Expand Down Expand Up @@ -167,7 +167,7 @@ def executeSaga(progress):
command,
shell=True,
stdout=subprocess.PIPE,
stdin=open(os.devnull),
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=True,
).stdout
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/saga/versioncheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def testDescriptionFile(f):
command,
shell=True,
stdout=subprocess.PIPE,
stdin=open(os.devnull),
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=True,
).stdout
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/taudem/TauDEMUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def executeTauDEM(command, progress):
fused_command,
shell=True,
stdout=subprocess.PIPE,
stdin=open(os.devnull),
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=True,
).stdout
Expand Down

0 comments on commit 0484769

Please sign in to comment.