]> SALOME platform Git repositories - modules/jobmanager.git/commitdiff
Salome HOME
Add preprocess command.
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Fri, 15 Dec 2017 15:52:59 +0000 (16:52 +0100)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Fri, 15 Dec 2017 15:52:59 +0000 (16:52 +0100)
src/engine/BL_Job.cxx
src/engine/BL_Job.hxx
src/engine/BL_SALOMEServices.cxx
src/genericgui/BL_CreateJobWizard.cxx
src/genericgui/BL_CreateJobWizard.hxx
src/genericgui/BL_JobsManager_QT.cxx

index a380c86b681556a00c7470b945d5090401358388..11ed0a13b106c7af93064e340d0343e7575364c0 100644 (file)
@@ -26,6 +26,7 @@ BL::Job::Job()
   _type = COMMAND;
   _job_file = "";
   _env_file = "";
+  _pre_command = "";
   _batch_params.batch_directory = "";
   _batch_params.maximum_duration = "";
   _batch_params.mem_limit = 0;
@@ -54,6 +55,7 @@ BL::Job::Job(const std::string & name)
   _type = COMMAND;
   _job_file = "";
   _env_file = "";
+  _pre_command = "";
   _batch_params.batch_directory = "";
   _batch_params.maximum_duration = "";
   _batch_params.mem_limit = 0;
@@ -167,6 +169,18 @@ BL::Job::getEnvFile()
   return _env_file;
 }
 
+void 
+BL::Job::setPreCommand(const std::string & pre_command)
+{
+  _pre_command = pre_command;
+}
+
+std::string & 
+BL::Job::getPreCommand()
+{
+  return _pre_command;
+}
+
 void 
 BL::Job::setBatchParameters(const BL::Job::BatchParam & param)
 {
index f2dc145d43fb3f359e44fb6c5ca9f3c2fd30ea09..532b31d5d4b6be18782cfc5d1bf2e340cc288e19 100644 (file)
@@ -53,6 +53,9 @@ namespace BL{
       void setEnvFile(const std::string & env_file);
       std::string & getEnvFile();
 
+      void setPreCommand(const std::string & pre_command);
+      std::string & getPreCommand();
+
       void setDumpYACSState(const int & dump_yacs_state);
       int getDumpYACSState();
 
@@ -124,6 +127,7 @@ namespace BL{
       BL::Job::JobType _type;
       std::string _job_file;
       std::string _env_file;
+      std::string _pre_command;
 
       BL::Job::BatchParam _batch_params;
       BL::Job::FilesParam _files_params;
index bc7e640e221ccf1efb4b1ae2c55e4a28ce44450b..1a1e0d627e73b7b29c3b026d517fbef72d949881 100644 (file)
@@ -299,6 +299,7 @@ BL::SALOMEServices::create_job(BL::Job * job)
   job_parameters->job_name = CORBA::string_dup(job->getName().c_str());
   job_parameters->job_file = CORBA::string_dup(job->getJobFile().c_str());
   job_parameters->env_file = CORBA::string_dup(job->getEnvFile().c_str());
+  job_parameters->pre_command = CORBA::string_dup(job->getPreCommand().c_str());
   BL::Job::FilesParam files = job->getFilesParameters();
   std::list<std::string>::iterator it;
   int i = 0;
@@ -630,6 +631,7 @@ BL::SALOMEServices::get_new_job(int job_number)
     job_return->setType(job_parameters->job_type.in());
     job_return->setJobFile(job_parameters->job_file.in());
     job_return->setEnvFile(job_parameters->env_file.in());
+    job_return->setPreCommand(job_parameters->pre_command.in());
     job_return->setBatchQueue(job_parameters->queue.in());
     job_return->setWCKey(job_parameters->wckey.in());
     job_return->setExtraParams(job_parameters->extra_params.in());
index eba7034998fc042bfae4e89f86ecb0d28a691209..f14ade824e9c8abe9648135b34ac498407f557d1 100644 (file)
@@ -56,6 +56,7 @@ BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALO
   command = "";
   python_salome_file = "";
   env_file = "";
+  pre_command = "";
   batch_directory = "";
 
   // For COORM
@@ -133,6 +134,7 @@ BL::CreateJobWizard::clone(const std::string & name)
       setField("yacs_file", QString(job->getJobFile().c_str()));
       setField("job_type_yacs", true);
       setField("env_yacs_file", QString(job->getEnvFile().c_str()));
+      setField("pre_yacs_file", QString(job->getPreCommand().c_str()));
       if (job->getDumpYACSState() != -1)
       {
         QString value;
@@ -149,29 +151,31 @@ BL::CreateJobWizard::clone(const std::string & name)
       setField("command", QString(job->getJobFile().c_str()));
       setField("job_type_command", true);
       setField("env_command_file", QString(job->getEnvFile().c_str()));
+      setField("pre_command_file", QString(job->getPreCommand().c_str()));
     }
     else if (job->getType() == BL::Job::PYTHON_SALOME)
     {
       setField("PythonSalome", QString(job->getJobFile().c_str()));
       setField("job_type_python_salome", true);
       setField("env_PythonSalome_file", QString(job->getEnvFile().c_str()));
+      setField("pre_PythonSalome_file", QString(job->getPreCommand().c_str()));
     }
 
 
-       // For COORM
+    // For COORM
     BL::Job::BatchParam batch_params = job->getBatchParameters();
-       BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(job->getResource().c_str());
-       std::string batch = resource_descr.batch.c_str();
-       if (batch == "coorm")
-       {
-               setField("coorm_batch_directory", QString(batch_params.batch_directory.c_str()));
-               setField("launcher_file", QString(batch_params.launcher_file.c_str()));
-               setField("launcher_args", QString(batch_params.launcher_args.c_str()));
-       }
-       else
-       {
-               setField("batch_directory", QString(batch_params.batch_directory.c_str()));
-       }
+    BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(job->getResource().c_str());
+    std::string batch = resource_descr.batch.c_str();
+    if (batch == "coorm")
+    {
+      setField("coorm_batch_directory", QString(batch_params.batch_directory.c_str()));
+      setField("launcher_file", QString(batch_params.launcher_file.c_str()));
+      setField("launcher_args", QString(batch_params.launcher_args.c_str()));
+    }
+    else
+    {
+      setField("batch_directory", QString(batch_params.batch_directory.c_str()));
+    }
 
     QString proc_value;
     proc_value.setNum(batch_params.nb_proc);
@@ -287,6 +291,15 @@ BL::CreateJobWizard::end(int result)
       f_env_file = field("env_PythonSalome_file").toString();
     env_file = f_env_file.trimmed().toUtf8().constData();
 
+    QString f_pre_command_file;
+    if (job_type == YACS)
+      f_pre_command_file = field("pre_yacs_file").toString();
+    else if (job_type == COMMAND)
+      f_pre_command_file = field("pre_command_file").toString();
+    else if (job_type == PYTHON_SALOME)
+      f_pre_command_file = field("pre_PythonSalome_file").toString();
+    pre_command = f_pre_command_file.trimmed().toUtf8().constData();
+
     // Batch Panel
     QString f_batch_directory = field("batch_directory").toString();
     batch_directory = f_batch_directory.trimmed().toUtf8().constData();
@@ -555,11 +568,19 @@ BL::YACSSchemaPage::YACSSchemaPage(QWidget * parent)
   _line_env_file = new QLineEdit(this);
   registerField("env_yacs_file", _line_env_file);
   _line_env_file->setReadOnly(true);
+  QPushButton * command_pre_command_button = new QPushButton(tr("Choose a pre processing script"));
+  connect(command_pre_command_button, SIGNAL(clicked()),
+          this, SLOT(choose_pre_command_file()));
+  _line_pre_command = new QLineEdit(this);
+  registerField("pre_yacs_file", _line_pre_command);
+  _line_pre_command->setReadOnly(true);
   QGridLayout * files_layout = new QGridLayout;
   files_layout->addWidget(yacs_file_button, 0, 0);
   files_layout->addWidget(_yacs_file_text, 0, 1);
   files_layout->addWidget(command_env_file_button, 1, 0);
   files_layout->addWidget(_line_env_file, 1, 1);
+  files_layout->addWidget(command_pre_command_button, 2, 0);
+  files_layout->addWidget(_line_pre_command, 2, 1);
   files_param_box->setLayout(files_layout);
 
   QGroupBox * spec_param_box = new QGroupBox("YACS specific parameters");
@@ -628,6 +649,16 @@ BL::YACSSchemaPage::choose_env_file()
   _line_env_file->setReadOnly(true);
 }
 
+void
+BL::YACSSchemaPage::choose_pre_command_file()
+{
+  QString pre_command_file = QFileDialog::getOpenFileName(this,
+                                                    tr("Open script file"), "",
+                                                    tr("All Files (*)"));
+  _line_pre_command->setReadOnly(false);
+  _line_pre_command->setText(pre_command_file);
+  _line_pre_command->setReadOnly(true);
+}
 
 int 
 BL::YACSSchemaPage::nextId() const
@@ -655,11 +686,20 @@ BL::CommandMainPage::CommandMainPage(QWidget * parent)
   registerField("env_command_file", _line_env_file);
   _line_env_file->setReadOnly(true);
 
+  QPushButton * command_pre_command_button = new QPushButton(tr("Choose a pre processing script"));
+  connect(command_pre_command_button, SIGNAL(clicked()),
+          this, SLOT(choose_pre_command_file()));
+  _line_pre_command = new QLineEdit(this);
+  registerField("pre_command_file", _line_pre_command);
+  _line_pre_command->setReadOnly(true);
+
   QGridLayout *layout = new QGridLayout;
   layout->addWidget(command_file_button, 0, 0);
   layout->addWidget(_line_command, 0, 1);
   layout->addWidget(command_env_file_button, 1, 0);
   layout->addWidget(_line_env_file, 1, 1);
+  layout->addWidget(command_pre_command_button, 2, 0);
+  layout->addWidget(_line_pre_command, 2, 1);
 
   QVBoxLayout * main_layout = new QVBoxLayout;
   main_layout->addWidget(label);
@@ -692,6 +732,17 @@ BL::CommandMainPage::choose_env_file()
   _line_env_file->setReadOnly(true);
 }
 
+void
+BL::CommandMainPage::choose_pre_command_file()
+{
+  QString pre_command_file = QFileDialog::getOpenFileName(this,
+                                                    tr("Open script file"), "",
+                                                    tr("All Files (*)"));
+  _line_pre_command->setReadOnly(false);
+  _line_pre_command->setText(pre_command_file);
+  _line_pre_command->setReadOnly(true);
+}
+
 bool
 BL::CommandMainPage::validatePage()
 {
@@ -1304,11 +1355,20 @@ BL::PythonSalomeMainPage::PythonSalomeMainPage(QWidget * parent)
   registerField("env_PythonSalome_file", _line_env_file);
   _line_env_file->setReadOnly(true);
 
+  QPushButton * command_pre_command_button = new QPushButton(tr("Choose a pre processing script"));
+  connect(command_pre_command_button, SIGNAL(clicked()),
+          this, SLOT(choose_pre_command_file()));
+  _line_pre_command = new QLineEdit(this);
+  registerField("pre_PythonSalome_file", _line_pre_command);
+  _line_pre_command->setReadOnly(true);
+
   QGridLayout *layout = new QGridLayout;
   layout->addWidget(PythonSalome_file_button, 0, 0);
   layout->addWidget(_line_PythonSalome, 0, 1);
   layout->addWidget(PythonSalome_env_file_button, 1, 0);
   layout->addWidget(_line_env_file, 1, 1);
+  layout->addWidget(command_pre_command_button, 2, 0);
+  layout->addWidget(_line_pre_command, 2, 1);
 
   QVBoxLayout * main_layout = new QVBoxLayout;
   main_layout->addWidget(label);
@@ -1341,6 +1401,17 @@ BL::PythonSalomeMainPage::choose_env_file()
   _line_env_file->setReadOnly(true);
 }
 
+void
+BL::PythonSalomeMainPage::choose_pre_command_file()
+{
+  QString pre_command_file = QFileDialog::getOpenFileName(this,
+                                                    tr("Open script file"), "",
+                                                    tr("All Files (*)"));
+  _line_pre_command->setReadOnly(false);
+  _line_pre_command->setText(pre_command_file);
+  _line_pre_command->setReadOnly(true);
+}
+
 bool
 BL::PythonSalomeMainPage::validatePage()
 {
index d2d0613de3b49c605d2f667d2b1e829f5815693a..84f8960397e2b9f6febbe5bee6b1c187a1cea516 100644 (file)
@@ -79,6 +79,7 @@ namespace BL {
       std::string python_salome_file;
 
       std::string env_file;
+      std::string pre_command;
 
       std::string batch_directory;
 
@@ -281,10 +282,12 @@ namespace BL {
     public slots:
       void choose_file();
       void choose_env_file();
+      void choose_pre_command_file();
 
     private:
       QLineEdit * _yacs_file_text;
       QLineEdit * _line_env_file;
+      QLineEdit * _line_pre_command;
   };
 
   class CommandMainPage: public QWizardPage
@@ -302,10 +305,12 @@ namespace BL {
     public slots:
       void choose_command_file();
       void choose_env_file();
+      void choose_pre_command_file();
 
     private:
       QLineEdit * _line_command;
       QLineEdit * _line_env_file;
+      QLineEdit * _line_pre_command;
   };
 
   class PythonSalomeMainPage: public QWizardPage
@@ -323,10 +328,12 @@ namespace BL {
     public slots:
       void choose_PythonSalome_file();
       void choose_env_file();
+      void choose_pre_command_file();
 
     private:
       QLineEdit * _line_PythonSalome;
       QLineEdit * _line_env_file;
+      QLineEdit * _line_pre_command;
   };
 
   class AdvancedParametersPage: public QWizardPage
index e56bde129d86812aa84a053fb9292ad164bb4df9..91ac18e3ee5b03a82862b8381320f0056d6e40b4 100644 (file)
@@ -309,6 +309,7 @@ BL::JobsManager_QT::create_job_with_wizard(BL::CreateJobWizard & wizard)
 
   // For all jobs
   new_job->setEnvFile(wizard.env_file);
+  new_job->setPreCommand(wizard.pre_command);
   BL::Job::BatchParam param;
 
   // For COORM