[FEM] fix solver console bugs

- for Elmer and Z88 on Windows several windows pop up (console windows). This is maybe annoying and the user is wondering what is going on, but the main problem is that when you close them, you break the solving process.
Therefore, on Windows only, hide the empty popup windows.
This commit is contained in:
Uwe
2022-07-11 01:38:44 +02:00
parent 842fd4772b
commit c8064ed059
4 changed files with 58 additions and 20 deletions

View File

@@ -121,10 +121,18 @@ class Solve(run.Solve):
if os.path.isdir(solvpath):
os.environ["ELMER_HOME"] = solvpath
os.environ["LD_LIBRARY_PATH"] = "$LD_LIBRARY_PATH:{}/modules".format(solvpath)
self._process = subprocess.Popen(
# hide the popups on Windows
if system() == "Windows":
self._process = subprocess.Popen(
[binary], cwd=self.directory,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
startupinfo=femutils.startProgramInfo("hide"))
else:
self._process = subprocess.Popen(
[binary], cwd=self.directory,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
self.signalAbort.add(self._process.terminate)
output = self._observeSolver(self._process)
self._process.communicate()

View File

@@ -33,6 +33,7 @@ import os
import os.path
import subprocess
import tempfile
from platform import system
from FreeCAD import Console
from FreeCAD import Units
@@ -223,7 +224,12 @@ class Writer(object):
unvPath,
"-scale", "0.001", "0.001", "0.001",
"-out", self.directory]
subprocess.call(args, stdout=subprocess.DEVNULL)
# hide the popups on Windows
if system() == "Windows":
subprocess.call(args, stdout=subprocess.DEVNULL,
startupinfo=femutils.startProgramInfo("hide"))
else:
subprocess.call(args, stdout=subprocess.DEVNULL)
def _writeStartinfo(self):
path = os.path.join(self.directory, _STARTINFO_NAME)

View File

@@ -31,6 +31,7 @@ __url__ = "https://www.freecadweb.org"
import os
import os.path
import subprocess
from platform import system
import FreeCAD
@@ -118,23 +119,28 @@ class Solve(run.Solve):
# TODO: search out for "Vector GS" and "Vector KOI" and print values
# may be compare with the used ones
self.pushStatus("Executing solver in test mode...\n")
self._process = subprocess.Popen(
[binary, "-t", "-" + solver],
cwd=self.directory,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
self.signalAbort.add(self._process.terminate)
self._process.communicate()
self.signalAbort.remove(self._process.terminate)
Solve.runZ88(self, "-t", binary, solver, "hide")
# run solver real mode
self.pushStatus("Executing solver in real mode...\n")
binary = settings.get_binary("Z88")
self._process = subprocess.Popen(
[binary, "-c", "-" + solver],
cwd=self.directory,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
# starting normal because the user must see the z88 window
Solve.runZ88(self, "-c", binary, solver, "normal")
def runZ88(self, command, binary, solver, state):
# minimize or hide the popups on Windows
if system() == "Windows":
self._process = subprocess.Popen(
[binary, command, "-" + solver],
cwd=self.directory,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
startupinfo=femutils.startProgramInfo(state))
else:
self._process = subprocess.Popen(
[binary, command, "-" + solver],
cwd=self.directory,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
self.signalAbort.add(self._process.terminate)
self._process.communicate()
self.signalAbort.remove(self._process.terminate)