Skip to content

Commit

Permalink
FEM: Add printCalculiXstdout function
Browse files Browse the repository at this point in the history
That non-critical part was quite often silently crashing with
UnicodeDecodeError and as a side effect FreeCAD wasn't loading perfectly
valid CalculiX result file. In long run that function should be replaced
with a write-to-log counterpart and the CalculiX stdout should be shown
to the user only upon request.

Signed-off-by: Przemo Firszt <przemo@firszt.eu>
  • Loading branch information
PrzemoF authored and wwmayer committed Mar 21, 2015
1 parent d693051 commit ec27cbc
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/Mod/Fem/MechanicalAnalysis.py
Expand Up @@ -252,12 +252,21 @@ def femConsoleMessage(self, message="", color="#000000"):
format(time.time() - self.Start, color, message)
self.form.textEdit_Output.setText(self.OutStr)

def printCalculiXstdout(self):
#There is probably no need to show user output from CalculiX. It should be
#written to a file in the calcs directory and shown to user upon request [BUTTON]
out = self.Calculix.readAllStandardOutput()
if out.isEmpty():
self.femConsoleMessage("CalculiX stdout is empty", "#FF0000")
else:
try:
self.femConsoleMessage(unicode(out).replace('\n','<br>'))
except UnicodeDecodeError:
self.femConsoleMessage("Error converting stdout from CalculiX", "#FF0000")

def UpdateText(self):
if(self.Calculix.state() == QtCore.QProcess.ProcessState.Running):
out = self.Calculix.readAllStandardOutput()
#print out
if out:
self.femConsoleMessage(unicode(out).replace('\n','<br>'))
self.printCalculiXstdout()
self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start) )

def calculixError(self, error):
Expand All @@ -280,11 +289,8 @@ def calculixStateChanged(self, newState):
def calculixFinished(self,exitCode):
print "calculixFinished()",exitCode
print self.Calculix.state()
out = self.Calculix.readAllStandardOutput()
print out
if out:
self.femConsoleMessage(unicode(out).replace('\n','<br>'))

self.printCalculiXstdout()
self.Timer.stop()

self.femConsoleMessage("Calculix done!", "#00FF00")
Expand Down

0 comments on commit ec27cbc

Please sign in to comment.