]> SALOME platform Git repositories - modules/hydrosolver.git/commitdiff
Salome HOME
Changing how run_study (running steering file from ihm) is done
authorYOANN AUDOUIN <B61570@dsp0851742.postes.calibre.edf.fr>
Fri, 30 Oct 2020 16:03:26 +0000 (17:03 +0100)
committerYOANN AUDOUIN <B61570@dsp0851742.postes.calibre.edf.fr>
Fri, 30 Oct 2020 16:04:19 +0000 (17:04 +0100)
src/salome_hydro/run_study/gui.py
src/salome_hydro/run_study/launcher.py

index 94be8735a12d94a11cf760915ad54cf528b1b9b6..7984fd47d7bdcd4a08f9ec359b62ff480f133f00 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 .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()
 
 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()
 
 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()
 
 def generate_job_for_selected_case_study():
   param_dict = get_params_from_selected_case()
index 8edb96f7c0813101ada7e26d4cce68d99413ff15..c14d1a5022b706daed32398232daa3b74acc1a6d 100644 (file)
@@ -50,26 +50,25 @@ def run_study(param_dict):
     orig_steering = f.read()
   orig_steering_lines = orig_steering.split("\n")
 
     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"]
 
   # 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):
   """
 
 def check_file_or_create_link(filepath, dirpath, interm_file_list = None):
   """