Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CfdOF/CfdConsoleProcess.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(self, finished_hook=None, stdout_hook=None, stderr_hook=None):
def __del__(self):
self.terminate()

#TODO document what the format of cmd is for developers
def start(self, cmd, env_vars=None, working_dir=None):
""" Start process and return immediately """
self.print_next_error_lines = 0
Expand Down Expand Up @@ -79,12 +80,18 @@ def terminate(self):
self.process.write(b"terminate\n")
self.process.waitForBytesWritten() # 'flush'
else:
print("Process has been terminated")
self.process.terminate()
self.process.waitForFinished()

def finished(self, exit_code):
print("Process has finished")
if self.finishedHook:
#print("finished hook was called with exit code:" + str(exit_code))
self.finishedHook(exit_code)
else:
pass
#print("Error: finished wasn't hooked to a handler")

def readStdout(self):
# Ensure only complete lines are passed on
Expand Down
22 changes: 21 additions & 1 deletion CfdOF/CfdPreferencePage.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def __init__(self):

self.form.tb_choose_output_dir.clicked.connect(self.chooseOutputDir)
self.form.le_output_dir.textChanged.connect(self.outputDirChanged)
self.form.cb_add_filename_to_output.clicked.connect(self.addFilenameChanged)

self.form.cb_docker_sel.clicked.connect(self.dockerCheckboxClicked)
self.form.pb_download_install_docker.clicked.connect(self.downloadInstallDocker)
Expand Down Expand Up @@ -145,6 +146,13 @@ def __init__(self):
def __del__(self):
self.cleanUp()

# This is a special version that only returns the base output path.
# The version in CfdTools.py returns the full output path, with the filename appended
def getDefaultOutputPath(self):
prefs = CfdTools.getPreferencesLocation()
output_path = FreeCAD.ParamGet(prefs).GetString("DefaultOutputPath", "")
return output_path

def cleanUp(self):
if self.thread and self.thread.isRunning():
FreeCAD.Console.PrintError("Terminating a pending install task\n")
Expand Down Expand Up @@ -179,7 +187,8 @@ def loadSettings(self):
self.initial_gmsh_path = str(self.gmsh_path)
self.form.le_gmsh_path.setText(self.gmsh_path)

self.output_dir = CfdTools.getDefaultOutputPath()
#self.output_dir = CfdTools.getDefaultOutputPath()
self.output_dir = self.getDefaultOutputPath()
self.form.le_output_dir.setText(self.output_dir)

if FreeCAD.ParamGet(prefs).GetBool("UseDocker", 0):
Expand All @@ -192,6 +201,13 @@ def loadSettings(self):

self.setDownloadURLs()

# disable add_filename_to_output for now.
# self.form.cb_add_filename_to_output.setEnabled(False)
if FreeCAD.ParamGet(prefs).GetBool("AddFilenameToOutput",0):
self.form.cb_add_filename_to_output.setChecked(True)
else:
self.form.cb_add_filename_to_output.setChecked(False)

def consoleMessage(self, message="", colour_type=None):
message = escape(message)
message = message.replace('\n', '<br>')
Expand All @@ -202,6 +218,10 @@ def consoleMessage(self, message="", colour_type=None):
self.form.textEdit_Output.setText(self.console_message)
self.form.textEdit_Output.moveCursor(QtGui.QTextCursor.End)

def addFilenameChanged(self):
prefs = CfdTools.getPreferencesLocation()
FreeCAD.ParamGet(prefs).SetBool("AddFilenameToOutput", self.form.cb_add_filename_to_output.isChecked())

def foamDirChanged(self, text):
self.foam_dir = text
if self.foam_dir and os.access(self.foam_dir, os.R_OK):
Expand Down
Loading