Salome HOME
corrections to new run via gui
authorYOANN AUDOUIN <B61570@dsp0919998.atlas.edf.fr>
Mon, 30 Nov 2020 16:37:10 +0000 (17:37 +0100)
committerYOANN AUDOUIN <B61570@dsp0919998.atlas.edf.fr>
Mon, 30 Nov 2020 16:37:10 +0000 (17:37 +0100)
src/salome_hydro/run_study/gui.py
src/salome_hydro/run_study/launcher.py

index 7984fd47d7bdcd4a08f9ec359b62ff480f133f00..30bf86617d9a342e3e9ae49ac3c6368dc3d2e05e 100755 (executable)
@@ -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, QMessageBox, QPlainTextEdit
+from PyQt5.QtWidgets import  QFileDialog, QMessageBox, QTextEdit
 
 def create_case_study():
     EficasForRunStudyAppli()
@@ -49,17 +49,18 @@ def get_params_from_selected_case():
 def run_selected_case_study():
   param_dict = get_params_from_selected_case()
 
-  QMessageBox.Information(view, view.tr("Information"),
-                          view.tr("The job is running."))
-  listing = run_study(param_dict)
+  view = sgPyQt.getDesktop()
 
-  # Display listing
-  dspl_listing = QPlainTextEdit(view)
-  dspl_listing.setReadOnly(True)
-
-  dspl_listing.setPlainText(tmp)
-
-  dspl_listing.show()
+  QMessageBox.information(view, "Information", "The job is running.")
+  passed, tmp = run_study(param_dict)
+  qmsg = QMessageBox(view)
+  qmsg.setIcon(QMessageBox.Information)
+  if passed:
+      qmsg.setText("Job successfull"+" "*80)
+  else:
+      qmsg.setText("Job failed"+" "*85)
+  qmsg.setDetailedText(tmp)
+  qmsg.exec_()
 
 def generate_job_for_selected_case_study():
   param_dict = get_params_from_selected_case()
index c14d1a5022b706daed32398232daa3b74acc1a6d..1328b4f5104e7898fdac326b0c14fce3b4ab9335 100644 (file)
@@ -50,24 +50,25 @@ def run_study(param_dict):
     orig_steering = f.read()
   orig_steering_lines = orig_steering.split("\n")
 
-  #TODO:  replace by call to Telemac Python (import runcode.py) ? for windows compatibility
-
 
   # Run the code itself
   code = param_dict["CODE"]
-  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)
+  cmd = "runcode.py {code} -w {wrkdir} {steering_filepath} -s" \
+         .format(code=code,
+                 wrkdir=wrkdir,
+                 steering_filepath=os.path.basename(steering_filepath))
 
   # 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)
+  logger.debug("Running the following command in salome shell in %s: %s", steering_file_dir, cmd)
+  try:
+      log = subprocess.check_output(cmd, cwd=steering_file_dir, shell=True)
+      passed = True
+      log = log.decode('utf-8')
+  except subprocess.CalledProcessError as e:
+      passed = False
+      log = str(e)
 
-  return log.decode('utf-8')
+  return passed, log
 
 
 def check_file_or_create_link(filepath, dirpath, interm_file_list = None):