From: ribes Date: Wed, 13 Jan 2010 16:40:54 +0000 (+0000) Subject: - Support "python_salome" launcher job type X-Git-Tag: V5_1_4a1~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=21f49cfe078de30fc83ebf6a1dfeaa0ba69f7e53;p=modules%2Fjobmanager.git - Support "python_salome" launcher job type --- diff --git a/src/engine/BL_Job.hxx b/src/engine/BL_Job.hxx index 0f63344..723fe4c 100644 --- a/src/engine/BL_Job.hxx +++ b/src/engine/BL_Job.hxx @@ -37,7 +37,7 @@ namespace BL{ void setName(const std::string & name); std::string getName(); - enum JobType {YACS_SCHEMA, COMMAND}; + enum JobType {YACS_SCHEMA, COMMAND, PYTHON_SALOME}; void setType(BL::Job::JobType type); BL::Job::JobType getType(); diff --git a/src/engine/BL_SALOMEServices.cxx b/src/engine/BL_SALOMEServices.cxx index 157a5bb..20c3a54 100644 --- a/src/engine/BL_SALOMEServices.cxx +++ b/src/engine/BL_SALOMEServices.cxx @@ -99,6 +99,10 @@ BL::SALOMEServices::create_job(BL::Job * job) { job_parameters->job_type = CORBA::string_dup("yacs_file"); } + else if (job->getType() == BL::Job::PYTHON_SALOME) + { + job_parameters->job_type = CORBA::string_dup("python_salome"); + } // Files job_parameters->job_file = CORBA::string_dup(job->getJobFile().c_str()); diff --git a/src/genericgui/BL_CreateJobWizard.cxx b/src/genericgui/BL_CreateJobWizard.cxx index 2839970..6d6e6d2 100644 --- a/src/genericgui/BL_CreateJobWizard.cxx +++ b/src/genericgui/BL_CreateJobWizard.cxx @@ -29,6 +29,7 @@ BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALO job_name = ""; yacs_file = ""; command = ""; + python_salome_file = ""; env_file = ""; batch_directory = ""; maximum_duration = ""; @@ -44,13 +45,17 @@ BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALO setOptions(QWizard::IndependentPages | QWizard::NoBackButtonOnStartPage); - setPage(Page_JobName, new BL::CreateJobWizard::JobNamePage(this, _jobs_manager)); - setPage(Page_YACSSchema, new BL::YACSSchemaPage(this)); + // Common pages + setPage(Page_JobName, new BL::JobNamePage(this, _jobs_manager)); setPage(Page_BatchParameters, new BL::BatchParametersPage(this)); setPage(Page_Files, new BL::FilesPage(this)); - setPage(Page_Command_Main_Definitions, new BL::CommandMainPage(this)); setPage(Page_Resource, new BL::ResourcePage(this, salome_services)); - setPage(Page_Conclusion, new BL::CreateJobWizard::ConclusionPage(this)); + setPage(Page_Conclusion, new BL::ConclusionPage(this)); + + // Specific pages + setPage(Page_YACSSchema, new BL::YACSSchemaPage(this)); + setPage(Page_Command_Main_Definitions, new BL::CommandMainPage(this)); + setPage(Page_PythonSalome_Main_Definitions, new BL::PythonSalomeMainPage(this)); setWindowTitle("Create Job Wizard"); connect(this, SIGNAL(finished(int)), this, SLOT(end(int))); @@ -86,12 +91,17 @@ BL::CreateJobWizard::end(int result) QString f_command = field("command").toString(); command = f_command.toStdString(); - QString f_env_file; + // Command Panel + QString f_python_salome_file = field("PythonSalome").toString(); + python_salome_file = f_python_salome_file.toStdString(); + QString f_env_file; if (yacs_file != "") f_env_file = field("env_yacs_file").toString(); - else + else if (command != "") f_env_file = field("env_command_file").toString(); + else if (python_salome_file != "") + f_env_file = field("env_PythonSalome_file").toString(); env_file = f_env_file.toStdString(); // Batch Panel @@ -148,7 +158,7 @@ BL::CreateJobWizard::end(int result) } // Job Name Page -BL::CreateJobWizard::JobNamePage::JobNamePage(QWidget * parent, BL::JobsManager_QT * jobs_manager) +BL::JobNamePage::JobNamePage(QWidget * parent, BL::JobsManager_QT * jobs_manager) : QWizardPage(parent) { _jobs_manager = jobs_manager; @@ -164,10 +174,12 @@ BL::CreateJobWizard::JobNamePage::JobNamePage(QWidget * parent, BL::JobsManager_ QGroupBox *groupBox = new QGroupBox(); _yacs_schema_button = new QRadioButton(tr("YACS Schema")); _yacs_schema_button->setChecked(true); - QRadioButton *radio2 = new QRadioButton(tr("Command")); + _command_button = new QRadioButton(tr("Command")); + _python_salome_button = new QRadioButton(tr("Python script in SALOME")); QVBoxLayout *vbox = new QVBoxLayout; vbox->addWidget(_yacs_schema_button); - vbox->addWidget(radio2); + vbox->addWidget(_command_button); + vbox->addWidget(_python_salome_button); vbox->addStretch(1); groupBox->setLayout(vbox); @@ -183,13 +195,13 @@ BL::CreateJobWizard::JobNamePage::JobNamePage(QWidget * parent, BL::JobsManager_ setLayout(main_layout); } -BL::CreateJobWizard::JobNamePage::~JobNamePage() +BL::JobNamePage::~JobNamePage() {} bool -BL::CreateJobWizard::JobNamePage::validatePage() +BL::JobNamePage::validatePage() { - DEBTRACE("Calling validatePage of BL::CreateJobWizard::JobNamePage"); + DEBTRACE("Calling validatePage of BL::JobNamePage"); bool return_value; QString job_name = field("job_name").toString(); @@ -219,16 +231,20 @@ BL::CreateJobWizard::JobNamePage::validatePage() } int -BL::CreateJobWizard::JobNamePage::nextId() const +BL::JobNamePage::nextId() const { if (_yacs_schema_button->isChecked()) { return BL::CreateJobWizard::Page_YACSSchema; } - else + else if (_command_button->isChecked()) { return BL::CreateJobWizard::Page_Command_Main_Definitions; } + else if (_python_salome_button->isChecked()) + { + return BL::CreateJobWizard::Page_PythonSalome_Main_Definitions; + } } BL::YACSSchemaPage::YACSSchemaPage(QWidget * parent) @@ -239,9 +255,9 @@ BL::YACSSchemaPage::YACSSchemaPage(QWidget * parent) QLabel *label = new QLabel("In this step you have to choose what YACS Schema you want to execute"); label->setWordWrap(true); - _yacs_file_button = new QPushButton(tr("Choose YACS Schema file")); - _yacs_file_button->show(); - connect(_yacs_file_button, SIGNAL(clicked()), this, SLOT(choose_file())); + QPushButton * yacs_file_button = new QPushButton(tr("Choose YACS Schema file")); + yacs_file_button->show(); + connect(yacs_file_button, SIGNAL(clicked()), this, SLOT(choose_file())); _yacs_file_text = new QLineEdit(this); _yacs_file_text->setText(""); @@ -258,7 +274,7 @@ BL::YACSSchemaPage::YACSSchemaPage(QWidget * parent) QVBoxLayout * main_layout = new QVBoxLayout; main_layout->addWidget(label); QGridLayout *layout = new QGridLayout; - layout->addWidget(_yacs_file_button, 0, 0); + layout->addWidget(yacs_file_button, 0, 0); layout->addWidget(_yacs_file_text, 0, 1); layout->addWidget(command_env_file_button, 1, 0); layout->addWidget(_line_env_file, 1, 1); @@ -659,7 +675,7 @@ BL::FilesPage::nextId() const return BL::CreateJobWizard::Page_Resource; } -BL::CreateJobWizard::ConclusionPage::ConclusionPage(QWidget * parent) +BL::ConclusionPage::ConclusionPage(QWidget * parent) : QWizardPage(parent) { setTitle("Job definition is finished"); @@ -670,17 +686,17 @@ BL::CreateJobWizard::ConclusionPage::ConclusionPage(QWidget * parent) setLayout(main_layout); }; -BL::CreateJobWizard::ConclusionPage::~ConclusionPage() +BL::ConclusionPage::~ConclusionPage() {} bool -BL::CreateJobWizard::ConclusionPage::validatePage() +BL::ConclusionPage::validatePage() { return true; } int -BL::CreateJobWizard::ConclusionPage::nextId() const +BL::ConclusionPage::nextId() const { return -1; } @@ -759,3 +775,81 @@ BL::ResourcePage::nextId() const { return BL::CreateJobWizard::Page_Conclusion; } + +BL::PythonSalomeMainPage::PythonSalomeMainPage(QWidget * parent) +: QWizardPage(parent) +{ + setTitle("Define a Python script in SALOME job"); + QLabel *label = new QLabel("Enter the Python script that will be executed into the resource"); + label->setWordWrap(true); + + // PythonSalome + QPushButton * PythonSalome_file_button = new QPushButton(tr("Choose a Python file")); + PythonSalome_file_button->show(); + connect(PythonSalome_file_button, SIGNAL(clicked()), this, SLOT(choose_PythonSalome_file())); + _line_PythonSalome = new QLineEdit(this); + registerField("PythonSalome", _line_PythonSalome); + _line_PythonSalome->setReadOnly(true); + + QPushButton * PythonSalome_env_file_button = new QPushButton(tr("Choose an environnement file")); + PythonSalome_env_file_button->show(); + connect(PythonSalome_env_file_button, SIGNAL(clicked()), this, SLOT(choose_env_file())); + _line_env_file = new QLineEdit(this); + registerField("env_PythonSalome_file", _line_env_file); + _line_env_file->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); + + QVBoxLayout * main_layout = new QVBoxLayout; + main_layout->addWidget(label); + main_layout->insertLayout(-1, layout); + setLayout(main_layout); +}; + +BL::PythonSalomeMainPage::~PythonSalomeMainPage() +{} + +void +BL::PythonSalomeMainPage::choose_PythonSalome_file() +{ + QString PythonSalome_file = QFileDialog::getOpenFileName(this, + tr("Open Python script file"), "", + tr("py (*.py);;All Files (*)")); + _line_PythonSalome->setReadOnly(false); + _line_PythonSalome->setText(PythonSalome_file); + _line_PythonSalome->setReadOnly(true); +} + +void +BL::PythonSalomeMainPage::choose_env_file() +{ + QString env_file = QFileDialog::getOpenFileName(this, + tr("Open environnement file"), "", + tr("sh (*.sh);;All Files (*)")); + _line_env_file->setReadOnly(false); + _line_env_file->setText(env_file); + _line_env_file->setReadOnly(true); +} + +bool +BL::PythonSalomeMainPage::validatePage() +{ + QString PythonSalome = field("PythonSalome").toString(); + if (PythonSalome == "") + { + QMessageBox::warning(NULL, "Python script in SALOME Error", "Please enter a Python script"); + return false; + } + + return true; +} + +int +BL::PythonSalomeMainPage::nextId() const +{ + return BL::CreateJobWizard::Page_BatchParameters; +} diff --git a/src/genericgui/BL_CreateJobWizard.hxx b/src/genericgui/BL_CreateJobWizard.hxx index ffd6612..20fdce6 100644 --- a/src/genericgui/BL_CreateJobWizard.hxx +++ b/src/genericgui/BL_CreateJobWizard.hxx @@ -57,8 +57,9 @@ namespace BL{ std::string job_name; std::string yacs_file; - std::string command; + std::string python_salome_file; + std::string env_file; std::string batch_directory; @@ -76,76 +77,40 @@ namespace BL{ bool start_job; public: - enum {Page_JobName, Page_YACSSchema, Page_BatchParameters, Page_Files, - Page_Command_Main_Definitions, Page_Resource, Page_Conclusion}; - - class JobNamePage: virtual public QWizardPage - { - public: - JobNamePage(QWidget * parent, BL::JobsManager_QT * jobs_manager); - virtual ~JobNamePage(); - - virtual bool validatePage(); - virtual int nextId() const ; - - private: - BL::JobsManager_QT * _jobs_manager; - QRadioButton * _yacs_schema_button; - }; - - - - class ConclusionPage: virtual public QWizardPage - { - public: - ConclusionPage(QWidget * parent); - virtual ~ConclusionPage(); - - virtual bool validatePage(); - virtual int nextId() const ; - }; + enum {Page_JobName, + Page_YACSSchema, + Page_Command_Main_Definitions, + Page_PythonSalome_Main_Definitions, + Page_BatchParameters, + Page_Files, + Page_Resource, + Page_Conclusion}; }; - class YACSSchemaPage: virtual public QWizardPage + class JobNamePage: virtual public QWizardPage { - Q_OBJECT - public: - YACSSchemaPage(QWidget * parent); - virtual ~YACSSchemaPage(); + JobNamePage(QWidget * parent, BL::JobsManager_QT * jobs_manager); + virtual ~JobNamePage(); virtual bool validatePage(); virtual int nextId() const ; - public slots: - void choose_file(); - void choose_env_file(); - - private: - QPushButton * _yacs_file_button; - QLineEdit * _yacs_file_text; - QLineEdit * _line_env_file; + private: + BL::JobsManager_QT * _jobs_manager; + QRadioButton * _yacs_schema_button; + QRadioButton * _command_button; + QRadioButton * _python_salome_button; }; - class CommandMainPage: virtual public QWizardPage + class ConclusionPage: virtual public QWizardPage { - Q_OBJECT - public: - CommandMainPage(QWidget * parent); - virtual ~CommandMainPage(); + ConclusionPage(QWidget * parent); + virtual ~ConclusionPage(); virtual bool validatePage(); virtual int nextId() const ; - - public slots: - void choose_command_file(); - void choose_env_file(); - - private: - QLineEdit * _line_command; - QLineEdit * _line_env_file; - }; class BatchParametersPage: virtual public QWizardPage @@ -209,6 +174,66 @@ namespace BL{ QLineEdit * _resource_choosed; BL::SALOMEServices * _salome_services; }; + + class YACSSchemaPage: virtual public QWizardPage + { + Q_OBJECT + + public: + YACSSchemaPage(QWidget * parent); + virtual ~YACSSchemaPage(); + + virtual bool validatePage(); + virtual int nextId() const ; + + public slots: + void choose_file(); + void choose_env_file(); + + private: + QLineEdit * _yacs_file_text; + QLineEdit * _line_env_file; + }; + + class CommandMainPage: virtual public QWizardPage + { + Q_OBJECT + + public: + CommandMainPage(QWidget * parent); + virtual ~CommandMainPage(); + + virtual bool validatePage(); + virtual int nextId() const ; + + public slots: + void choose_command_file(); + void choose_env_file(); + + private: + QLineEdit * _line_command; + QLineEdit * _line_env_file; + }; + + class PythonSalomeMainPage: virtual public QWizardPage + { + Q_OBJECT + + public: + PythonSalomeMainPage(QWidget * parent); + virtual ~PythonSalomeMainPage(); + + virtual bool validatePage(); + virtual int nextId() const ; + + public slots: + void choose_PythonSalome_file(); + void choose_env_file(); + + private: + QLineEdit * _line_PythonSalome; + QLineEdit * _line_env_file; + }; } #endif diff --git a/src/genericgui/BL_JobTab.cxx b/src/genericgui/BL_JobTab.cxx index cd23a9d..5c8cab4 100644 --- a/src/genericgui/BL_JobTab.cxx +++ b/src/genericgui/BL_JobTab.cxx @@ -171,8 +171,10 @@ BL::JobTab::job_selected(const QModelIndex & index) _job_envfile_label_value->setText(QString(job->getEnvFile().c_str())); if (job->getType() == BL::Job::YACS_SCHEMA) _job_type_label_value->setText("YACS_Schema"); - else + else if (job->getType() == BL::Job::COMMAND) _job_type_label_value->setText("Command"); + else if (job->getType() == BL::Job::PYTHON_SALOME) + _job_type_label_value->setText("Python_Salome"); _job_resource_label_value->setText(QString(job->getResource().c_str())); diff --git a/src/genericgui/BL_JobsManager_QT.cxx b/src/genericgui/BL_JobsManager_QT.cxx index 3c0db89..97e25c9 100644 --- a/src/genericgui/BL_JobsManager_QT.cxx +++ b/src/genericgui/BL_JobsManager_QT.cxx @@ -162,12 +162,18 @@ BL::JobsManager_QT::create_job_wizard() new_job->setType(BL::Job::YACS_SCHEMA); new_job->setJobFile(wizard.yacs_file); } - else + else if (wizard.command != "") { // Command Job new_job->setType(BL::Job::COMMAND); new_job->setJobFile(wizard.command); } + else if (wizard.python_salome_file != "") + { + // Command Job + new_job->setType(BL::Job::PYTHON_SALOME); + new_job->setJobFile(wizard.python_salome_file); + } // For all jobs new_job->setEnvFile(wizard.env_file); diff --git a/src/genericgui/BL_QModelManager.cxx b/src/genericgui/BL_QModelManager.cxx index e806ac7..ad0d4b9 100644 --- a/src/genericgui/BL_QModelManager.cxx +++ b/src/genericgui/BL_QModelManager.cxx @@ -53,8 +53,10 @@ BL::QModelManager::new_job_added(const QString & name) QStandardItem * new_job_type; if (job->getType() == BL::Job::YACS_SCHEMA) new_job_type = new QStandardItem("YACS_Schema"); - else + else if (job->getType() == BL::Job::COMMAND) new_job_type = new QStandardItem("Command"); + else if (job->getType() == BL::Job::PYTHON_SALOME) + new_job_type = new QStandardItem("Python_Salome"); QStandardItem * new_job_state; if (job->getState() == BL::Job::CREATED)