Skip to content
Permalink
Browse files

[processing] Use subprocess.DEVNULL instead of open(os.devnull)

  • Loading branch information
nyalldawson committed Nov 7, 2016
1 parent 6a99017 commit 0484769b7d1817b365efe706600fc9b97669651e
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)
@@ -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, ""):
@@ -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,
)
@@ -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
@@ -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,
)
@@ -81,7 +81,7 @@ def createDescriptionFiles(self):
command,
shell=True,
stdout=f,
stdin=open(os.devnull),
stdin=subprocess.DEVNULL,
stderr=f,
universal_newlines=True,
)
@@ -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
@@ -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
@@ -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
@@ -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

0 comments on commit 0484769

Please sign in to comment.
You can’t perform that action at this time.