From 51e096e0762409c46d067b92eb6da40f0314d547 Mon Sep 17 00:00:00 2001 From: YOANN AUDOUIN Date: Fri, 30 Oct 2020 17:03:26 +0100 Subject: [PATCH] Changing how run_study (running steering file from ihm) is done --- src/salome_hydro/run_study/gui.py | 15 ++++++++++++-- src/salome_hydro/run_study/launcher.py | 27 +++++++++++++------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/salome_hydro/run_study/gui.py b/src/salome_hydro/run_study/gui.py index 94be873..7984fd4 100755 --- a/src/salome_hydro/run_study/gui.py +++ b/src/salome_hydro/run_study/gui.py @@ -25,7 +25,7 @@ from salome.hydro.run_study.eficas.appli import EficasForRunStudyAppli from .launcher import run_study from .genjobwindow import GenJobDialog -from PyQt5.QtWidgets import QFileDialog +from PyQt5.QtWidgets import QFileDialog, QMessageBox, QPlainTextEdit def create_case_study(): EficasForRunStudyAppli() @@ -48,7 +48,18 @@ def get_params_from_selected_case(): def run_selected_case_study(): param_dict = get_params_from_selected_case() - run_study(param_dict) + + QMessageBox.Information(view, view.tr("Information"), + view.tr("The job is running.")) + listing = run_study(param_dict) + + # Display listing + dspl_listing = QPlainTextEdit(view) + dspl_listing.setReadOnly(True) + + dspl_listing.setPlainText(tmp) + + dspl_listing.show() def generate_job_for_selected_case_study(): param_dict = get_params_from_selected_case() diff --git a/src/salome_hydro/run_study/launcher.py b/src/salome_hydro/run_study/launcher.py index 8edb96f..c14d1a5 100644 --- a/src/salome_hydro/run_study/launcher.py +++ b/src/salome_hydro/run_study/launcher.py @@ -50,26 +50,25 @@ def run_study(param_dict): orig_steering = f.read() orig_steering_lines = orig_steering.split("\n") - cmd = "set -x ; " + #TODO: replace by call to Telemac Python (import runcode.py) ? for windows compatibility + # Run the code itself code = param_dict["CODE"] - cmd += "cd %s && runcode.py -w %s %s %s" % \ - (steering_file_dir, wrkdir, code, steering_filepath) - cmd += " ; rc=$?" + listing_name = "run.log" + listing = os.path.join(steering_file_dir, '..', listing_name) + cmd = "runcode.py {code} {steering_filepath}" \ + .format(steering_file_dir=steering_file_dir, + code=code, + steering_filepath=os.path.basename(steering_filepath), + listing=listing_name) - # Cleanup intermediate files if the computation was successful - cmd += " ; if test $rc -eq 0; then rm -rf %s ; fi" % " ".join(interm_files) + # Launch the command + logger.debug("Running the following command in salome shell in %s: %s", wrkdir, cmd) + log = subprocess.check_output(cmd, cwd=wrkdir, shell=True) - cmd += ' ; echo "return code is $rc"' + return log.decode('utf-8') - # Launch the command - logger.debug("Running the following command in xterm: %s" % cmd) - args = ["xterm", "-T", "Execution of Telemac", "-geo", "80x60", "-hold", "-l", "-e", cmd] - if 'batchExec' in param_dict: - if param_dict['batchExec'] == True: - args = ["xterm", "-T", "Execution of Telemac", "-geo", "80x60", "+hold", "-l", "-e", cmd] - subprocess.Popen(args, cwd = wrkdir) def check_file_or_create_link(filepath, dirpath, interm_file_list = None): """ -- 2.39.2