Skip to content
Permalink
Browse files

Merge pull request #1604 from elpaso/processing

[processing] Avoid python hangs when run in headless mode from FCGI
  • Loading branch information
volaya committed Oct 3, 2014
2 parents ac54c8e + 59ec15b commit f5054a1e724308189efbfa00c457d046aa293e05
@@ -73,7 +73,7 @@ def runGdal(commands, progress):
fused_command,
shell=True,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stdin=open(os.devnull),
stderr=subprocess.STDOUT,
universal_newlines=False,
).stdout
@@ -270,7 +270,7 @@ def executeGrass(commands, progress, outputCommands=None):
command,
shell=True,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stdin=open(os.devnull),
stderr=subprocess.STDOUT,
universal_newlines=True,
).stdout
@@ -299,7 +299,7 @@ def executeGrass(commands, progress, outputCommands=None):
command,
shell=True,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stdin=open(os.devnull),
stderr=subprocess.STDOUT,
universal_newlines=True,
).stdout
@@ -272,7 +272,7 @@ def executeGrass7(commands, progress, outputCommands=None):
command,
shell=True,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stdin=open(os.devnull),
stderr=subprocess.STDOUT,
universal_newlines=True,
).stdout
@@ -301,7 +301,7 @@ def executeGrass7(commands, progress, outputCommands=None):
command,
shell=True,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stdin=open(os.devnull),
stderr=subprocess.STDOUT,
universal_newlines=True,
).stdout
@@ -67,7 +67,7 @@ def runFusion(commands, progress):
commands,
shell=True,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stdin=open(os.devnull),
stderr=subprocess.STDOUT,
universal_newlines=False,
).stdout
@@ -46,7 +46,7 @@ def runLAStools(commands, progress):
loglines = []
loglines.append("LAStools console output")
commandline = " ".join(commands)
proc = subprocess.Popen(commandline, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,
proc = subprocess.Popen(commandline, shell=True, stdout=subprocess.PIPE, stdin=open(os.devnull),
stderr=subprocess.STDOUT, universal_newlines=False).stdout
for line in iter(proc.readline, ""):
loglines.append(line)
@@ -131,7 +131,7 @@ def executeOtb(commands, progress):
loglines.append("OTB execution console output")
os.putenv('ITK_AUTOLOAD_PATH', OTBUtils.otbLibPath())
fused_command = ''.join(['"%s" ' % c for c in commands])
proc = subprocess.Popen(fused_command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=True).stdout
proc = subprocess.Popen(fused_command, shell=True, stdout=subprocess.PIPE, stdin=open(os.devnull),stderr=subprocess.STDOUT, universal_newlines=True).stdout
for line in iter(proc.readline, ""):
if "[*" in line:
idx = line.find("[*")
@@ -103,7 +103,7 @@ def executeRAlgorithm(alg, progress):
command,
shell=True,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stdin=open(os.devnull),
stderr=subprocess.STDOUT,
universal_newlines=True,
)
@@ -171,7 +171,7 @@ def checkRIsInstalled(ignoreRegistrySettings=False):
command,
shell=True,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stdin=open(os.devnull),
stderr=subprocess.STDOUT,
universal_newlines=True,
).stdout
@@ -41,7 +41,7 @@ def createLibraryFiles(self):
command,
shell=True,
stdout=f2,
stdin=subprocess.PIPE,
stdin=open(os.devnull),
stderr=subprocess.STDOUT,
universal_newlines=True,
)
@@ -77,7 +77,7 @@ def createDescriptionFiles(self):
command,
shell=True,
stdout=f,
stdin=subprocess.PIPE,
stdin=open(os.devnull),
stderr=f,
universal_newlines=True,
)
@@ -128,7 +128,7 @@ def executeSaga(progress):
command,
shell=True,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stdin=open(os.devnull),
stderr=subprocess.STDOUT,
universal_newlines=True,
).stdout
@@ -86,7 +86,7 @@ def executeTauDEM(command, progress):
fused_command,
shell=True,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stdin=open(os.devnull),
stderr=subprocess.STDOUT,
universal_newlines=True,
).stdout
@@ -323,20 +323,23 @@ def runAlgorithm(algOrName, onFinish, *args):
print 'Warning: Not all input layers use the same CRS.\n' \
+ 'This can cause unexpected results.'

# Don't set the wait cursor twice, because then when you
# restore it, it will still be a wait cursor.
cursor = QApplication.overrideCursor()
if cursor is None or cursor == 0:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
elif cursor.shape() != Qt.WaitCursor:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
if iface is not None:
# Don't set the wait cursor twice, because then when you
# restore it, it will still be a wait cursor.
cursor = QApplication.overrideCursor()
if cursor is None or cursor == 0:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
elif cursor.shape() != Qt.WaitCursor:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))

progress = None
if iface is not None :
progress = MessageBarProgress()
ret = runalg(alg, progress)
if onFinish is not None and ret:
onFinish(alg, progress)
QApplication.restoreOverrideCursor()
progress.close()

if iface is not None:
QApplication.restoreOverrideCursor()
progress.close()
return alg

0 comments on commit f5054a1

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