def solver_command(self, **kw): """ Returns a tuple indicating the solver's working directory, executable path, and associated command-line arguments. """ return enquote_arg(self.exec_dir), enquote_arg(self.solver_path), ''
def solver_command(self, **kw): """ Returns a tuple indicating the solver's working directory, executable path, and associated command-line arguments. """ return enquote_arg(self.exec_dir), enquote_arg(self.solver_path), ''
def run_autovnv_command(_c, _log, pythondir=None): """ Run command with arguments. Redirection of the stdout or stderr of the command. """ assert type(_c) == str or type(_c) == unicode log.debug("run_autovnv_command: %s" % _c) try: _log.seek(0, os.SEEK_END) except: _log.seek(0, 2) def __text(_t): return "\n\nExecution failed --> %s: %s" \ "\n - command: %s" \ "\n - directory: %s\n\n" % \ (_t, str(retcode), _c, os.getcwd()) _l = "" cmd = separate_args(_c) env = os.environ.copy() if pythondir: pythondir = enquote_arg(pythondir) pythonpath = pythondir + ':' + env.get("PYTHONPATH", '') env.update([("PYTHONPATH", pythonpath)]) try: t1 = time.time() retcode = run_command(cmd, stdout=_log, stderr=_log, env=env) t2 = time.time() if retcode < 0: _l = __text("command was terminated by signal") elif retcode > 0: _l = __text("command return") except OSError: import traceback import sys exc_info = sys.exc_info() bt = traceback.format_exception(*exc_info) for l in bt: _log.write(l) retcode = 0 del exc_info _l = __text("unknown command") t1 = 0. t2 = 0. _log.flush() if _l: _log.write(_l) return retcode, "%.2f" % (t2 - t1)
def solver_command(self, **kw): """ Returns a tuple indicating SYRTHES's working directory, executable path, and associated command-line arguments. """ wd = enquote_arg(self.exec_dir) # Working directory exec_path = enquote_arg(self.solver_path) # Executable # Build kernel command-line arguments args = '' args += ' -d ' + enquote_arg(self.syrthes_case.data_file) args += ' -n ' + str(self.syrthes_case.n_procs) if self.syrthes_case.n_procs_ray > 0: args += ' -r ' + str(self.n_procs_ray) args += ' --name ' + enquote_arg(self.name) # Output to a logfile args += ' --log ' + enquote_arg(self.logfile) # Adjust for Valgrind if used if self.valgrind != None: args = enquote_arg(self.solver_path) + ' ' + args exec_path = '' for a in separate_args(self.valgrind): exec_path += enquote_arg(a) + ' ' return wd, exec_path, args
def set_compute_build(self, parameters): """ Set the compute-build option in the run command """ line = self.lines[self.run_cmd_line_id] args = update_command_single_value( separate_args(line), ('--compute-build', '--compute-build='), enquote_arg(parameters)) self.lines[self.run_cmd_line_id] = assemble_args(args)
def set_coupling(self, coupling): """ Set the coupling option in the run command """ line = self.lines[self.run_cmd_line_id] args = update_command_single_value(separate_args(line), ('--coupling', ), enquote_arg(coupling)) self.lines[self.run_cmd_line_id] = assemble_args(args)
def set_nprocs(self, parameters): """ Set the nprocs option in the run command """ line = self.lines[self.run_cmd_line_id] args = update_command_single_value(separate_args(line), ('--nprocs', '--nprocs=', '-n'), enquote_arg(parameters)) self.lines[self.run_cmd_line_id] = assemble_args(args)
def set_run_id(self, run_id=None, run_id_prefix=None, run_id_suffix=None): """ Set the run id, id_prefix, and id_suffix options in the run command """ line = self.lines[self.run_cmd_line_id] args = separate_args(line) if run_id != None: args = update_command_single_value(args, ('--id', '--id='), enquote_arg(run_id)) if run_id_prefix != None: args = update_command_single_value(args, ('--id-prefix', '--id-prefix='), enquote_arg(run_id_prefix)) if run_id_suffix != None: args = update_command_single_value(args, ('--id-suffix', '--id-suffix='), enquote_arg(run_id_suffix)) self.lines[self.run_cmd_line_id] = assemble_args(args)
def __suggest_run_id(self): """ Return an id. """ cmd = os.path.join(self.case['package'].get_dir('bindir'), self.case['package'].name) cmd = cs_exec_environment.enquote_arg(cmd) + " run --suggest-id" xmlfile = self.case['xmlfile'] if xmlfile: cmd += " --param " + cs_exec_environment.enquote_arg(xmlfile) r_title = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, universal_newlines=True).stdout.read()[:-1] r_id = os.path.join(self.case['resu_path'], r_title) run_id = r_id run_title = r_title return os.path.basename(run_id), run_title
def set_nprocs(self, parameters): """ Set the nprocs option in the run command """ line = self.lines[self.run_cmd_line_id] args = update_command_single_value(separate_args(line), ('--nprocs', '--nprocs=', '-n'), enquote_arg(parameters)) self.lines[self.run_cmd_line_id] = assemble_args(args)
def set_coupling(self, coupling): """ Set the coupling option in the run command """ line = self.lines[self.run_cmd_line_id] args = update_command_single_value(separate_args(line), ('--coupling',), enquote_arg(coupling)) self.lines[self.run_cmd_line_id] = assemble_args(args)
def solver_command(self, **kw): """ Returns a tuple indicating SYRTHES's working directory, executable path, and associated command-line arguments. """ wd = enquote_arg(self.exec_dir) # Working directory exec_path = enquote_arg(self.solver_path) # Executable # Build kernel command-line arguments args = '' args += ' -d ' + enquote_arg(self.syrthes_case.data_file) args += ' -n ' + str(self.syrthes_case.n_procs) if self.syrthes_case.n_procs_ray > 0: args += ' -r ' + str(self.n_procs_ray) args += ' --name ' + enquote_arg(self.name) # Output to a logfile args += ' --log ' + enquote_arg(self.logfile) # Adjust for Debug if used if self.debug != None: args = enquote_arg(self.solver_path) + ' ' + args exec_path = self.debug_wrapper_args(self.debug) return wd, exec_path, args
def set_run_id(self, run_id=None, run_id_prefix=None, run_id_suffix=None): """ Set the run id, id_prefix, and id_suffix options in the run command """ line = self.lines[self.run_cmd_line_id] args = separate_args(line) if run_id != None: args = update_command_single_value(args, ('--id', '--id='), enquote_arg(run_id)) if run_id_prefix != None: args = update_command_single_value(args, ('--id-prefix', '--id-prefix='), enquote_arg(run_id_prefix)) if run_id_suffix != None: args = update_command_single_value(args, ('--id-suffix', '--id-suffix='), enquote_arg(run_id_suffix)) self.lines[self.run_cmd_line_id] = assemble_args(args)
def __suggest_run_id(self): cmd = enquote_arg(os.path.join(self.pkg.get_dir('bindir'), self.exe)) + " run --suggest-id" p = subprocess.Popen(cmd, shell=True, executable=get_shell_type(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) i = p.communicate()[0] run_id = string.join(i.split()) return run_id, os.path.join(self.__dest, self.label, "RESU", run_id)
def set_nthreads(self, parameters): """ Set the nthreads option in the run command """ line = self.lines[self.run_cmd_line_id] args = update_command_single_value( separate_args(line), ('--threads-per-task', '--threads-per-task=', '-nt'), enquote_arg(parameters)) self.lines[self.run_cmd_line_id] = assemble_args(args)
def set_nthreads(self, parameters): """ Set the nthreads option in the run command """ line = self.lines[self.run_cmd_line_id] args = update_command_single_value(separate_args(line), ('--threads-per-task', '--threads-per-task=', '-nt'), enquote_arg(parameters)) self.lines[self.run_cmd_line_id] = assemble_args(args)
def debug_wrapper_args(self, debug_cmd): """ Additional arguments to use debug wrapper """ debug_args = '' python_exec = self.package.config.python if os.path.isfile(python_exec) or os.path.islink(python_exec): debug_args += python_exec + ' ' else: debug_args += 'python ' if self.package.name != 'neptune_cfd': pkg_dir = self.package.get_dir('pkgpythondir') dbg_wrapper_path = os.path.join(pkg_dir, 'cs_debug_wrapper.py') debug_args += dbg_wrapper_path + ' ' for a in separate_args(debug_cmd): debug_args += enquote_arg(a) + ' ' return debug_args
def solver_command(self, **kw): """ Returns a tuple indicating the solver's working directory, executable path, and associated command-line arguments. """ wd = enquote_arg(self.exec_dir) # Working directory exec_path = enquote_arg(self.solver_path) # Executable # Build kernel command-line arguments args = '' if self.param != None: args += ' --param ' + enquote_arg(self.param) if self.logging_args != None: args += ' ' + self.logging_args if self.solver_args != None: args += ' ' + self.solver_args if self.package_compute.config.features['mpi'] == 'yes': if self.name != None: args += ' --mpi --app-name ' + enquote_arg(self.name) elif self.n_procs > 1: args += ' --mpi' # Add FSI coupling (using SALOME YACS) if required if hasattr(self, 'fsi_aster'): if not sys.platform.startswith('linux'): raise RunCaseError(' Coupling with Code_Aster only avalaible on Linux.') salome_module = os.path.join(self.package_compute.get_dir('libdir'), 'salome', 'libFSI_SATURNEExelib.so') if os.path.isfile(salome_module): args += ' --yacs-module=' + enquote_arg(salome_module) # Adjust for Valgrind if used if self.valgrind != None: args = enquote_arg(self.solver_path) + ' ' + args exec_path = '' for a in separate_args(self.valgrind): exec_path += enquote_arg(a) + ' ' return wd, exec_path, args
def __suggest_run_id(self): """ Return an id. """ cmd = os.path.join(self.case['package'].get_dir('bindir'), self.case['package'].name) cmd = cs_exec_environment.enquote_arg(cmd) + " run --suggest-id" if self.mdl.getRunType() != "standard": cmd += " --id-prefix=preprocess" r_title = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, universal_newlines=True).stdout.read()[:-1] r_id = os.path.join(self.case['resu_path'], r_title) run_id = r_id run_title = r_title return os.path.basename(run_id), run_title
def __suggest_run_id(self): """ Return an id. """ cmd = os.path.join(self.case['package'].get_dir('bindir'), self.case['package'].name) cmd = cs_exec_environment.enquote_arg(cmd) + " run --suggest-id" r_title = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout.read()[:-1] r_id = os.path.join(self.case['resu_path'], r_title) run_id = r_id run_title = r_title j = 1 while os.path.isdir(run_id): j += 1 run_id = r_id + "_" + str(j) run_title = r_title + "(" + str(j) + ")" return os.path.basename(run_id), run_title
def solver_command(self, **kw): """ Returns a tuple indicating the solver's working directory, executable path, and associated command-line arguments. """ wd = enquote_arg(self.exec_dir) # Working directory exec_path = enquote_arg(self.solver_path) # Executable # Build kernel command-line arguments args = '' if self.param != None: args += ' --param ' + enquote_arg(self.param) if self.logging_args != None: args += ' ' + self.logging_args if self.solver_args != None: args += ' ' + self.solver_args if self.package_compute.config.features['mpi'] == 'yes': if self.name != None: args += ' --mpi --app-name ' + enquote_arg(self.name) elif self.n_procs > 1: args += ' --mpi' # Add FSI coupling (using SALOME YACS) if required if hasattr(self, 'fsi_aster'): if not sys.platform.startswith('linux'): raise RunCaseError( ' Coupling with Code_Aster only avalaible on Linux.') salome_module = os.path.join( self.package_compute.get_dir('libdir'), 'salome', 'libFSI_SATURNEExelib.so') if os.path.isfile(salome_module): args += ' --yacs-module=' + enquote_arg(salome_module) # Adjust for debugger if used if self.debug != None: args = enquote_arg(self.solver_path) + ' ' + args exec_path = self.debug_wrapper_args(self.debug) return wd, exec_path, args
def runAutoverif(pkg, opt_f, opt_v, opt_u, opt_x, opt_t, opt_r, opt_n, opt_c, opt_d, opt_p, opt_l, opt_to, opt_z): """ Main function 1. parse the command line, 2. read the file of parameters 3. create all studies, 4. compile sources 5. run all cases 6. compare results 7. plot result 8. reporting by mail """ # Source environment if required before importing Autovnv modules, as it # pulls Python packages such as matplotlib or vtk which may not be in the # standard path. from cs_exec_environment import set_modules, source_rcfile, enquote_arg set_modules(pkg) source_rcfile(pkg) from autovnv.Study import Studies # Scripts exe = os.path.join(pkg.get_dir('bindir'), pkg.name) if sys.platform.startswith('win'): exe = exe + ".com" exe = enquote_arg(exe) dif = pkg.get_io_dump() for p in exe, dif: if not os.path.isfile(p): print("Error: executable %s not found." % p) if not sys.platform.startswith('win'): sys.exit(1) dif += " -d" # Read the file of parameters studies = Studies(pkg, opt_f, opt_v, opt_x, opt_r, opt_n, opt_c, opt_d, opt_p, exe, dif, opt_l, opt_z) if opt_x == False: os.chdir(studies.getDestination()) else: os.chdir(studies.getRepository()) # Print header studies.reporting(" ----------") studies.reporting(" Auto V & V") studies.reporting(" ----------\n") studies.reporting(" Code name: " + pkg.name) studies.reporting(" Kernel version: " + pkg.version) studies.reporting(" Install directory: " + pkg.get_dir('exec_prefix')) studies.reporting(" File dump: " + dif) studies.reporting(" Repository: " + studies.getRepository()) studies.reporting(" Destination: " + studies.getDestination()) studies.reporting("\n Informations:") studies.reporting(" -------------\n") studies.reporting(" Date: " + datetime.now().strftime("%A %B %d %H:%M:%S %Y")) studies.reporting(" Platform: " + platform.platform()) studies.reporting(" Computer: " + platform.uname()[1] + " " + release()) studies.reporting(" Process Id: " + str(os.getpid())) studies.reporting(" User name: " + getpass.getuser()) studies.reporting(" Working directory: " + os.getcwd()) studies.reporting("\n") # Update repository if needed if opt_u: studies.updateRepository() sys.exit(0) # Update only xml data if needed if opt_x: studies.updateRepository(True) sys.exit(0) # Check if xml for result directories in the repository are OK if opt_c: studies.check_compare(destination=False) if opt_p: studies.check_script(destination=False) studies.check_plot(destination=False) # Create all studies and all cases studies.createStudies() # Compile sources of all cases if opt_t: studies.compilation() # Preprocessing and run all cases if opt_r: studies.run() # Compare checkpoint files if opt_c: studies.check_compare() studies.compare() # Postprocess results and probes if opt_p: studies.check_script() studies.scripts() studies.check_plot() studies.postpro() studies.plot() studies.reporting("\n -----------------") studies.reporting(" End of Auto V & V") studies.reporting(" -----------------") # Reporting attached_file = studies.build_reports("report_global", "report_detailed") if opt_to: sendmail(pkg.code_name, studies.logs(), studies.getlabel(), opt_to, attached_file)
def run_studymanager(pkg, options): """ Main function 1. parse the command line, 2. read the file of parameters 3. create all studies, 4. compile sources 5. run all cases 6. compare results 7. plot result 8. reporting by mail """ # Source environment if required before importing studymanager modules, as # it pulls Python packages such as matplotlib which may not be in # the standard path. from cs_exec_environment import set_modules, source_rcfile, enquote_arg set_modules(pkg) source_rcfile(pkg) from studymanager.cs_studymanager_study import Studies # Scripts exe = os.path.join(pkg.get_dir('bindir'), pkg.name) if sys.platform.startswith('win'): exe = exe + ".com" exe = enquote_arg(exe) dif = pkg.get_io_dump() for p in exe, dif: if not os.path.isfile(p): print("Error: executable %s not found." % p) if not sys.platform.startswith('win'): return 1 dif += " -d" # Read the file of parameters studies = Studies(pkg, options, exe, dif) if options.debug: print(" run_studymanager() >> Studies are initialized") if options.update_xml == False: os.chdir(studies.getDestination()) else: os.chdir(studies.getRepository()) # Print header studies.reporting(" -------------") studies.reporting(" Study Manager") studies.reporting(" -------------\n") studies.reporting(" Code name: " + pkg.name) studies.reporting(" Kernel version: " + pkg.version) studies.reporting(" Install directory: " + pkg.get_dir('exec_prefix')) studies.reporting(" File dump: " + dif) studies.reporting(" Repository: " + studies.getRepository()) studies.reporting(" Destination: " + studies.getDestination()) studies.reporting("\n Informations:") studies.reporting(" -------------\n") studies.reporting(" Date: " + datetime.now().strftime("%A %B %d %H:%M:%S %Y")) studies.reporting(" Platform: " + platform.platform()) studies.reporting(" Computer: " + platform.uname()[1] + " " + release()) studies.reporting(" Process Id: " + str(os.getpid())) studies.reporting(" User name: " + getpass.getuser()) studies.reporting(" Working directory: " + os.getcwd()) studies.reporting("\n") # Update repository if needed if options.update: studies.updateRepository() # Update only xml data if needed if options.update_xml: studies.updateRepository(True) # Test sources compilation for all cases if options.test_compilation: studies.test_compilation() # Check if xml for result directories in the repository are OK if options.compare: studies.check_compare(destination=False) if options.post: studies.check_script(destination=False) studies.check_plots_and_input(destination=False) # Create all studies and all cases if options.compare or options.post or options.runcase: studies.create_studies() # Preprocessing and run all cases if options.debug: print(" run_studymanager() >> Starts running...") if options.runcase: studies.run() if options.debug: print(" run_studymanager() >> Exits runs") # Compare checkpoint files if options.compare: studies.check_compare() studies.compare() # Postprocess results and probes if options.post: checked_scripts = studies.check_script() if checked_scripts: studies.scripts() studies.check_plots_and_input() studies.postpro() studies.plot() studies.reporting("\n --------------------") studies.reporting(" End of Study Manager") studies.reporting(" --------------------") # Reporting - attached files are either pdf or # raw tex files if pdflatex is disabled attached_file = studies.build_reports("report_global", "report_detailed") if len(options.addresses.split()) > 0: send_report(pkg.code_name, studies.logs(), studies.getlabel(), options.addresses.split(), attached_file) return 0
def main(argv, pkg): """ Main function. """ # Use alternate compute (back-end) package if defined batch = cs_batch.batch(pkg) submit_cmd = batch.submit_command_prefix() if not submit_cmd: submit_cmd = get_shell_type() runcase_path = process_cmd_line(argv, submit_cmd, pkg) if not runcase_path: return 1 scripts_dir = os.path.abspath(os.path.dirname(runcase_path)) runcase = cs_runcase.runcase(runcase_path) # Adjust run command for staging only run_args = runcase.get_run_args() for a in ['--stage', '--initialize', '--execute', '--finalize']: while a in run_args: run_args.remove(a) run_args.append('--stage') retcode, run_id, result_path = cs_run.run(run_args, pkg) # Now prepare runcase for submission if retcode != 0 or not result_path: err_str = ' run not staged due to prior error.' raise Exception(err_str) run_args = runcase.get_run_args() while '--stage' in run_args: run_args.remove(a) stages = [] for a in ['--initialize', '--execute', '--finalize']: if a in run_args: stages.append(a) if not stages: run_args.append('--initialize') run_args.append('--finalize') runcase.set_run_args(run_args) runcase.set_run_id(run_id=run_id) runcase_path = os.path.join(result_path, os.path.basename(runcase_path)) runcase.save(runcase_path) # Now submit case save_wd = os.getcwd() os.chdir(result_path) for a in argv: if os.path.isfile(a) and runcase_path: submit_cmd += ' ' + enquote_arg(runcase_path) runcase_path = None else: submit_cmd += ' ' + enquote_arg(a) return subprocess.call(submit_cmd, shell=True) os.chdir(save_wd)
def runAutoverif(pkg, opt_f, opt_v, opt_u, opt_x, opt_t, opt_r, opt_n, opt_c, opt_d, opt_p, opt_l, opt_to): """ Main function 1. parse the command line, 2. read the file of parameters 3. create all studies, 4. compile sources 5. run all cases 6. compare results 7. plot result 8. reporting by mail """ # Source environment if required before importing Autovnv modules, as it # pulls Python packages such as matplotlib or vtk which may not be in the # standard path. from cs_exec_environment import set_modules, source_rcfile, enquote_arg set_modules(pkg) source_rcfile(pkg) from autovnv.Study import Studies # Scripts exe = os.path.join(pkg.get_dir('bindir'), pkg.name) if sys.platform.startswith('win'): exe = exe + ".com" exe = enquote_arg(exe) dif = pkg.get_io_dump() for p in exe, dif: if not os.path.isfile(p): print("Error: executable %s not found." % p) if not sys.platform.startswith('win'): sys.exit(1) dif += " -d" # Read the file of parameters studies = Studies(pkg, opt_f, opt_v, opt_x, opt_r, opt_n, opt_c, opt_d, opt_p, exe, dif, opt_l) if opt_x == False: os.chdir(studies.getDestination()) else: os.chdir(studies.getRepository()) # Print header studies.reporting(" ----------") studies.reporting(" Auto V & V") studies.reporting(" ----------\n") studies.reporting(" Code name: " + pkg.name) studies.reporting(" Kernel version: " + pkg.version) studies.reporting(" Install directory: " + pkg.get_dir('exec_prefix')) studies.reporting(" File dump: " + dif) studies.reporting(" Repository: " + studies.getRepository()) studies.reporting(" Destination: " + studies.getDestination()) studies.reporting("\n Informations:") studies.reporting(" -------------\n") studies.reporting(" Date: " + datetime.now().strftime("%A %B %d %H:%M:%S %Y")) studies.reporting(" Platform: " + platform.platform()) studies.reporting(" Computer: " + platform.uname()[1] + " " + release()) studies.reporting(" Process Id: " + str(os.getpid())) studies.reporting(" User name: " + getpass.getuser()) studies.reporting(" Working directory: " + os.getcwd()) studies.reporting("\n") # Update repository if needed if opt_u: studies.updateRepository() sys.exit(0) # Update only xml data if needed if opt_x: studies.updateRepository(True) sys.exit(0) # Check if xml for result directories in the repository are OK if opt_c: studies.check_compare(destination=False) if opt_p: studies.check_script(destination=False) studies.check_plot(destination=False) # Create all studies and all cases studies.createStudies() # Compile sources of all cases if opt_t: studies.compilation() # Preprocessing and run all cases if opt_r: studies.run() # Compare checkpoint files if opt_c: studies.check_compare() studies.compare() # Postprocess results and probes if opt_p: studies.check_script() studies.scripts() studies.check_plot() studies.postpro() studies.plot() studies.reporting("\n -----------------") studies.reporting(" End of Auto V & V") studies.reporting(" -----------------") # Reporting attached_file = studies.build_reports("report_global", "report_detailed") if opt_to: sendmail(pkg.code_name, studies.logs(), studies.getlabel(), opt_to, attached_file)
def slotBatchRunning(self): """ Launch Code_Saturne batch running. """ # Is the file saved? if not self.__caseIsSaved__(): #self.parent.fileSave(renew_page=False) self.parent.fileSave(renew_page=True) self.__updateRunButton__ if not self.__caseIsSaved__(): title = self.tr("Warning") msg = self.tr("The current case must be saved before "\ "running the computation script.") QMessageBox.information(self, title, msg) return # Ensure code is run from a case subdirectory prv_dir = os.getcwd() os.chdir(self.case['scripts_path']) # Do we have a mesh ? have_mesh = False node_ecs = self.case.xmlGetNode('solution_domain') if node_ecs.xmlGetNode('meshes_list'): if node_ecs.xmlGetNode('meshes_list').xmlGetNodeList('mesh'): have_mesh = True if node_ecs.xmlGetNode('mesh_input', 'path'): have_mesh = True if not have_mesh: title = self.tr("Warning") msg = self.tr("You have to select a mesh.\n\n") QMessageBox.information(self, title, msg) return # Verify if boundary condition definitions exist if self.case['run_type'] == 'standard': bd = LocalizationModel('BoundaryZone', self.case) if not bd.getZones(): if self.case['no_boundary_conditions'] == False: title = self.tr("Warning") msg = self.tr("No boundary definition declared.\n\n") QMessageBox.warning(self, title, msg) self.case['no_boundary_conditions'] = True # Build command line rm_type = self.jmdl.batch.rm_type batch = self.case['runcase'].path cmd = None run_title = None run_id = self.jmdl.dictValues['run_id'] if rm_type == None: if not run_id: tmp_run_id, run_title = self.__suggest_run_id() self.__updateRuncase(tmp_run_id) else: run_title = self.case['package'].code_name + run_id cmd = cs_exec_environment.enquote_arg(batch) else: run_title = self.case['package'].code_name + ' - Job Submission' cmd = cs_exec_environment.enquote_arg(sys.argv[0]) \ + ' submit ' + cs_exec_environment.enquote_arg(batch) dlg = ListingDialogView(self.parent, self.case, run_title, cmd) dlg.show() if rm_type == None and not run_id: self.__updateRuncase('') # remove --id <id> from runcase os.chdir(prv_dir)
msg = self.tr("No boundary definition declared.\n\n") QMessageBox.warning(self, title, msg) self.case['no_boundary_conditions'] = True # Build command line rm_type = self.jmdl.batch.rm_type batch = self.case['runcase'].path cmd = None run_title = None if rm_type == None: run_id, run_title = self.__suggest_run_id() self.__updateRuncase(run_id) cmd = cs_exec_environment.enquote_arg(batch) else: run_title = self.case['package'].code_name + ' - Job Submission' cmd = cs_exec_environment.enquote_arg(sys.argv[0]) \ + ' submit ' + cs_exec_environment.enquote_arg(batch) dlg = ListingDialogView(self.parent, self.case, run_title, cmd) dlg.show() if rm_type == None: self.__updateRuncase('') # remove --id <id> from runcase os.chdir(prv_dir) def __suggest_run_id(self): """
def slotBatchRunning(self): """ Launch Code_Saturne batch running. """ # Is the file saved? if self.case['new'] == "yes" or len(self.case['undo']) > 0 or len(self.case['redo']) > 0: title = self.tr("Warning") msg = self.tr("The current case must be saved before "\ "running the ") + self.tr(self.case['package']).code_name + self.tr(" script.") QMessageBox.information(self, title, msg) return # Ensure code is run from a case subdirectory prv_dir = os.getcwd() os.chdir(self.case['scripts_path']) # Do we have a mesh ? have_mesh = False node_ecs = self.case.xmlGetNode('solution_domain') if node_ecs.xmlGetNode('meshes_list'): if node_ecs.xmlGetNode('meshes_list').xmlGetNodeList('mesh'): have_mesh = True if node_ecs.xmlGetNode('mesh_input', 'path'): have_mesh = True if not have_mesh: title = self.tr("Warning") msg = self.tr("You have to select a mesh.\n\n") QMessageBox.information(self, title, msg) return # Verify if boundary condition definitions exist bd = LocalizationModel('BoundaryZone', self.case) if not bd.getZones(): if self.case['no_boundary_conditions'] == False: title = self.tr("Warning") msg = self.tr("No boundary definition declared.\n\n") QMessageBox.warning(self, title, msg) self.case['no_boundary_conditions'] = True # Build command line key = self.case['batch_type'] batch = cs_exec_environment.enquote_arg(self.case['runcase'].path) if key == None: run_id, run_title = self.__suggest_run_id() self.__updateRuncase(run_id) cmd = batch key = 'localhost' elif key[0:3] == 'CCC': cmd = 'msub ' + batch elif key[0:5] == 'LOADL': cmd = 'llsubmit ' + batch elif key[0:3] == 'LSF': cmd = 'bsub < ' + batch elif key[0:3] == 'PBS' or key[0:3] == 'SGE': cmd = 'qsub ' + batch elif key[0:5] == 'SLURM': cmd = 'sbatch ' + batch else: pass if self.case['salome'] or key == 'localhost': dlg = ListingDialogView(self.parent, self.case, run_title, cmd) dlg.show() else: cs_exec_environment.run_command(cmd) if self.case['salome'] or key == 'localhost': self.__updateRuncase('') # remove --id <id> from runcase os.chdir(prv_dir)