From 0abfa38747338699ab6d51ab98e809131a48a997 Mon Sep 17 00:00:00 2001 From: ribes Date: Tue, 20 Mar 2012 13:25:58 +0000 Subject: [PATCH] Resolve PAL#2078 If a resource defines a working directory, the value is used as a base directory for a job remote working directory. --- src/genericgui/BL_CreateJobWizard.cxx | 71 ++++++++++++++++++++------- src/genericgui/BL_CreateJobWizard.hxx | 17 ++++++- src/genericgui/JM_ResourceCatalog.cxx | 20 ++++---- src/genericgui/JM_SalomeResource.cxx | 5 +- 4 files changed, 80 insertions(+), 33 deletions(-) diff --git a/src/genericgui/BL_CreateJobWizard.cxx b/src/genericgui/BL_CreateJobWizard.cxx index 328dc3d..703d235 100644 --- a/src/genericgui/BL_CreateJobWizard.cxx +++ b/src/genericgui/BL_CreateJobWizard.cxx @@ -25,6 +25,7 @@ #endif #include #include +#include #ifdef WNT #undef ERROR @@ -57,13 +58,13 @@ BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALO dump_yacs_state = -1; ll_jobtype = ""; - setOptions(QWizard::IndependentPages | QWizard::NoBackButtonOnStartPage); + setOptions(QWizard::NoBackButtonOnStartPage); // Common pages _job_name_page = new BL::JobNamePage(this, _jobs_manager); setPage(Page_JobName, _job_name_page); - setPage(Page_BatchParameters, new BL::BatchParametersPage(this)); + setPage(Page_BatchParameters, new BL::BatchParametersPage(this, salome_services)); setPage(Page_Files, new BL::FilesPage(this)); setPage(Page_Resource, new BL::ResourcePage(this, salome_services)); setPage(Page_Conclusion, new BL::ConclusionPage(this)); @@ -490,8 +491,8 @@ void BL::YACSSchemaPage::choose_file() { QString yacs_file = QFileDialog::getOpenFileName(this, - tr("Open YACS files"), "", - tr("XML (*.xml);;All Files (*)")); + tr("Open YACS files"), "", + tr("XML (*.xml);;All Files (*)")); _yacs_file_text->setReadOnly(false); _yacs_file_text->setText(yacs_file); _yacs_file_text->setReadOnly(true); @@ -501,8 +502,8 @@ void BL::YACSSchemaPage::choose_env_file() { QString env_file = QFileDialog::getOpenFileName(this, - tr("Open environnement file"), "", - tr("sh (*.sh);;All Files (*)")); + 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); @@ -512,7 +513,7 @@ BL::YACSSchemaPage::choose_env_file() int BL::YACSSchemaPage::nextId() const { - return BL::CreateJobWizard::Page_BatchParameters; + return BL::CreateJobWizard::Page_Resource; } BL::CommandMainPage::CommandMainPage(QWidget * parent) @@ -554,8 +555,8 @@ void BL::CommandMainPage::choose_command_file() { QString command_file = QFileDialog::getOpenFileName(this, - tr("Open command file"), "", - tr("sh (*.sh);;All Files (*)")); + tr("Open command file"), "", + tr("sh (*.sh);;All Files (*)")); _line_command->setReadOnly(false); _line_command->setText(command_file); _line_command->setReadOnly(true); @@ -565,8 +566,8 @@ void BL::CommandMainPage::choose_env_file() { QString env_file = QFileDialog::getOpenFileName(this, - tr("Open environnement file"), "", - tr("sh (*.sh);;All Files (*)")); + 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); @@ -588,13 +589,16 @@ BL::CommandMainPage::validatePage() int BL::CommandMainPage::nextId() const { - return BL::CreateJobWizard::Page_BatchParameters; + return BL::CreateJobWizard::Page_Resource; } -BL::BatchParametersPage::BatchParametersPage(QWidget * parent) +BL::BatchParametersPage::BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services) : QWizardPage(parent) { setTitle("Enter Batch Parameters"); + resource_choosed = ""; + + _salome_services = salome_services; QLabel *label = new QLabel("In this step you define the parameters of your job"); label->setWordWrap(true); @@ -660,6 +664,37 @@ BL::BatchParametersPage::BatchParametersPage(QWidget * parent) BL::BatchParametersPage::~BatchParametersPage() {} +void BL::BatchParametersPage::cleanupPage() {} + +void +BL::BatchParametersPage::initializePage() +{ + QString f_resource_choosed = field("resource_choosed").toString(); + if (f_resource_choosed != resource_choosed) + { + resource_choosed = f_resource_choosed; + // If choosed resource has a working_directory set + // Generates a default remote working directory + BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(resource_choosed.toStdString()); + QString res_work_dir = resource_descr.working_directory.c_str(); + if (res_work_dir != "") + { + time_t rawtime; + time(&rawtime); + std::string launch_date = ctime(&rawtime); + for (int i = 0; i < launch_date.size(); i++) + if (launch_date[i] == '/' || + launch_date[i] == '-' || + launch_date[i] == ':' || + launch_date[i] == ' ') + launch_date[i] = '_'; + launch_date.erase(--launch_date.end()); // Last caracter is a \n + QString date = launch_date.c_str(); + setField("batch_directory", res_work_dir + "/" + date); + } + } +} + bool BL::BatchParametersPage::validatePage() { @@ -796,8 +831,8 @@ void BL::FilesPage::choose_input_files() { QStringList files = QFileDialog::getOpenFileNames(this, - tr("Add input files"), "", - tr("All Files (*)")); + tr("Add input files"), "", + tr("All Files (*)")); for (int i = 0; i < files.size(); ++i) { if (_input_files_list->findItems(files.at(i), Qt::MatchFixedString).size() == 0) @@ -868,7 +903,7 @@ BL::FilesPage::output_itemSelectionChanged() int BL::FilesPage::nextId() const { - return BL::CreateJobWizard::Page_Resource; + return BL::CreateJobWizard::Page_Conclusion; } BL::ConclusionPage::ConclusionPage(QWidget * parent) @@ -1009,7 +1044,7 @@ BL::ResourcePage::itemSelected(QListWidgetItem * item) int BL::ResourcePage::nextId() const { - return BL::CreateJobWizard::Page_Conclusion; + return BL::CreateJobWizard::Page_BatchParameters; } BL::PythonSalomeMainPage::PythonSalomeMainPage(QWidget * parent) @@ -1085,5 +1120,5 @@ BL::PythonSalomeMainPage::validatePage() int BL::PythonSalomeMainPage::nextId() const { - return BL::CreateJobWizard::Page_BatchParameters; + return BL::CreateJobWizard::Page_Resource; } diff --git a/src/genericgui/BL_CreateJobWizard.hxx b/src/genericgui/BL_CreateJobWizard.hxx index 6a0d096..e039e97 100644 --- a/src/genericgui/BL_CreateJobWizard.hxx +++ b/src/genericgui/BL_CreateJobWizard.hxx @@ -105,13 +105,14 @@ namespace BL{ virtual bool validatePage(); virtual int nextId() const ; + virtual void cleanupPage() {} public slots: void yacs_schema_button(bool checked); void command_button(bool checked); void python_salome_button(bool checked); - private: + private: BL::JobsManager_QT * _jobs_manager; QLabel * _explanation; @@ -130,6 +131,7 @@ namespace BL{ virtual bool validatePage(); virtual int nextId() const ; + virtual void cleanupPage() {} }; class BatchParametersPage: virtual public QWizardPage @@ -137,11 +139,17 @@ namespace BL{ Q_OBJECT public: - BatchParametersPage(QWidget * parent); + BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services); virtual ~BatchParametersPage(); virtual bool validatePage(); virtual int nextId() const; + virtual void cleanupPage(); + virtual void initializePage(); + + private: + BL::SALOMEServices * _salome_services; + QString resource_choosed; }; class FilesPage: virtual public QWizardPage @@ -154,6 +162,7 @@ namespace BL{ virtual int nextId() const; virtual bool validatePage(); + virtual void cleanupPage() {} public slots: void choose_input_files(); @@ -187,6 +196,7 @@ namespace BL{ virtual int nextId() const; virtual bool validatePage(); virtual void initializePage(); + virtual void cleanupPage() {} public slots: void itemSelected(QListWidgetItem * item); @@ -211,6 +221,7 @@ namespace BL{ virtual bool validatePage(); virtual int nextId() const ; + virtual void cleanupPage() {} public slots: void choose_file(); @@ -231,6 +242,7 @@ namespace BL{ virtual bool validatePage(); virtual int nextId() const ; + virtual void cleanupPage() {} public slots: void choose_command_file(); @@ -251,6 +263,7 @@ namespace BL{ virtual bool validatePage(); virtual int nextId() const ; + virtual void cleanupPage() {} public slots: void choose_PythonSalome_file(); diff --git a/src/genericgui/JM_ResourceCatalog.cxx b/src/genericgui/JM_ResourceCatalog.cxx index c95b74e..74d18bf 100644 --- a/src/genericgui/JM_ResourceCatalog.cxx +++ b/src/genericgui/JM_ResourceCatalog.cxx @@ -29,7 +29,7 @@ JM::ResourceCatalog::ResourceCatalog(QWidget *parent, BL::SALOMEServices * salom BL_ASSERT(salome_services); _parent = parent; _salome_services = salome_services; - + _refresh_button = new QPushButton("Refresh Resource List"); _refresh_button->show(); _resource_files_list = new QListWidget(this); @@ -63,7 +63,7 @@ JM::ResourceCatalog::ResourceCatalog(QWidget *parent, BL::SALOMEServices * salom mainLayout->addWidget(_resource_files_list); mainLayout->addWidget(layout_widget); setLayout(mainLayout); - + // Buttons connect(_refresh_button, SIGNAL(clicked()), this, SLOT(refresh_resource_list())); connect(_show_button, SIGNAL(clicked()), this, SLOT(show_button())); @@ -104,9 +104,9 @@ void JM::ResourceCatalog::item_choosed(QListWidgetItem * item) { DEBTRACE("JM::ResourceCatalog::item_choosed"); - JM::SalomeResource * resource_widget = new JM::SalomeResource(this, - _salome_services, - item->text().toStdString()); + JM::SalomeResource * resource_widget = new JM::SalomeResource(this, + _salome_services, + item->text().toStdString()); resource_widget->exec(); delete resource_widget; } @@ -141,8 +141,8 @@ JM::ResourceCatalog::show_button() void JM::ResourceCatalog::add_button() { - JM::EditSalomeResource * resource_widget = new JM::EditSalomeResource(this, - _salome_services); + JM::EditSalomeResource * resource_widget = new JM::EditSalomeResource(this, + _salome_services); resource_widget->exec(); delete resource_widget; refresh_resource_list(); @@ -162,9 +162,9 @@ JM::ResourceCatalog::edit_button() { QList item_list = _resource_files_list->selectedItems(); QString item_name = item_list.at(0)->text(); - JM::EditSalomeResource * resource_widget = new JM::EditSalomeResource(this, - _salome_services, - item_name.toStdString()); + JM::EditSalomeResource * resource_widget = new JM::EditSalomeResource(this, + _salome_services, + item_name.toStdString()); resource_widget->exec(); delete resource_widget; refresh_resource_list(); diff --git a/src/genericgui/JM_SalomeResource.cxx b/src/genericgui/JM_SalomeResource.cxx index 500de29..1c81f36 100644 --- a/src/genericgui/JM_SalomeResource.cxx +++ b/src/genericgui/JM_SalomeResource.cxx @@ -21,7 +21,7 @@ #include "BL_Traces.hxx" JM::SalomeResource::SalomeResource(QWidget *parent, BL::SALOMEServices * salome_services, - const std::string & resource_name) : QDialog(parent) + const std::string & resource_name) : QDialog(parent) { DEBTRACE("Creating JM::SalomeResource"); BL_ASSERT(parent); @@ -68,7 +68,6 @@ JM::SalomeResource::SalomeResource(QWidget *parent, BL::SALOMEServices * salome_ m_layout->addWidget(working_directory_label, 7, 0); m_layout->addWidget(_working_directory, 7, 1); main_groupBox->setLayout(m_layout); - QGroupBox * config_groupBox = new QGroupBox("Configuration values"); QLabel * os_label = new QLabel("OS:"); @@ -156,7 +155,7 @@ void JM::SalomeResource::get_infos() { BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(_resource_name); - + _name_line->setText(QString(resource_descr.name.c_str())); _hostname_line->setText(QString(resource_descr.hostname.c_str())); _protocol_line->setText(QString(resource_descr.protocol.c_str())); -- 2.39.2