Пример #1
0
chue_t
CUpdaterComponentTray::update_internal() {
  QString str_tray_path = tray_path();
  if (str_tray_path.isEmpty()) return CHUE_FAILED;

  QString str_tray_download_path = download_tray_path();

  std::vector<CGorjunFileInfo> fi = CRestWorker::Instance()->get_gorjun_file_info(
                                      tray_kurjun_file_name());

  if (fi.empty()) {
    qCritical("File %s isn't presented on kurjun", m_component_id.toStdString().c_str());
    return CHUE_NOT_ON_KURJUN;
  }

  std::vector<CGorjunFileInfo>::iterator item = fi.begin();
  CExecutableUpdater *eu = new CExecutableUpdater(str_tray_download_path,
                                                  str_tray_path);

  if (item->md5_sum() == CCommons::FileMd5(str_tray_download_path)) {
    qInfo("Already have new version of tray in %s",
                  str_tray_download_path.toStdString().c_str());
    this->update_progress_sl(100, 100);
    connect(eu, &CExecutableUpdater::finished,
            this, &CUpdaterComponentTray::update_finished_sl);
    connect(eu, &CExecutableUpdater::finished,
            eu, &CExecutableUpdater::deleteLater);
    eu->replace_executables(true);
    return CHUE_SUCCESS;
  }

  CDownloadFileManager *dm = new CDownloadFileManager(item->name(),
                                                      str_tray_download_path,
                                                      item->size());
  dm->set_link(ipfs_download_url().arg(item->id(), item->name()));

  connect(dm, &CDownloadFileManager::download_progress_sig,
          this, &CUpdaterComponentTray::update_progress_sl);

  connect(dm, &CDownloadFileManager::finished, eu, &CExecutableUpdater::replace_executables);
  connect(eu, &CExecutableUpdater::finished, this, &CUpdaterComponentTray::update_finished_sl);
  connect(eu, &CExecutableUpdater::finished, dm, &CDownloadFileManager::deleteLater);
  connect(eu, &CExecutableUpdater::finished, eu, &CExecutableUpdater::deleteLater);

  dm->start_download();
  return CHUE_SUCCESS;
}
Пример #2
0
void
TrayControlWindow::updater_timer_timeout() {
  m_ss_updater_timer.stop();
  int exit_code = 0;

  /*subutai update*/
  CSystemCallWrapper::run_ss_updater(CSettingsManager::Instance().rh_host().toStdString().c_str(),
                                     CSettingsManager::Instance().rh_port().toStdString().c_str(),
                                     CSettingsManager::Instance().rh_user().toStdString().c_str(),
                                     CSettingsManager::Instance().rh_pass().toStdString().c_str(),
                                     exit_code);

  if (exit_code == RLE_SUCCESS) {
    CNotifiactionObserver::NotifyAboutInfo("Update command succesfull finished");
    CApplicationLog::Instance()->LogInfo("Update command succesfull finished");
  } else {
    QString err_msg = QString("Update command failed with exit code : %1").arg(exit_code);
    CNotifiactionObserver::NotifyAboutError(err_msg);
    CApplicationLog::Instance()->LogError(err_msg.toStdString().c_str());
  }

  /*tray update*/
  auto fi = CRestWorker::Instance()->get_gorjun_file_info(UPDATE_FILE_TO_REPLACE);
  if (!fi.empty()) {
    auto item = fi.begin();
    QString new_file_path = QApplication::applicationDirPath() +
                            QDir::separator() +
                            QString(UPDATE_FILE_TO_REPLACE);

    CDownloadFileManager *dm = new CDownloadFileManager(item->id(),
                                                        new_file_path,
                                                        item->size());
    CExecutableUpdater *eu = new CExecutableUpdater(new_file_path,
                                                    QApplication::applicationFilePath());

    dm->start_download();
    connect(dm, SIGNAL(finished()), eu, SLOT(replace_executables()));
    connect(eu, SIGNAL(finished()), dm, SLOT(deleteLater()));
    connect(eu, SIGNAL(finished()), eu, SLOT(deleteLater()));
  }

  m_ss_updater_timer.start();
}
Пример #3
0
chue_t CUpdaterComponentVAGRANT::install_internal() {
  QString version = "undefined";
  qDebug() << "Starting install vagrant";

  QMessageBox *msg_box = new QMessageBox(
      QMessageBox::Information, QObject::tr("Attention!"),
      QObject::tr(
          "<a href='https://www.vagrantup.com/intro/index.html'>Vagrant</a>"
          " is used to build and manage virtual machine environments.<br>"
          "Vagrant will be installed on your machine.<br>"
          "Do you want to proceed?"),
      QMessageBox::Yes | QMessageBox::No);
  msg_box->setTextFormat(Qt::RichText);

  QObject::connect(msg_box, &QMessageBox::finished, msg_box,
                   &QMessageBox::deleteLater);
  if (msg_box->exec() != QMessageBox::Yes) {
    install_finished_sl(false, version);
    return CHUE_SUCCESS;
  }
  QString file_name = vagrant_kurjun_package_name();
  QString file_dir = download_vagrant_path();
  QString str_vagrant_downloaded_path = file_dir + "/" + file_name;

  std::vector<CGorjunFileInfo> fi =
      CRestWorker::Instance()->get_gorjun_file_info(file_name);
  if (fi.empty()) {
    qCritical("File %s isn't presented on kurjun",
              m_component_id.toStdString().c_str());
    install_finished_sl(false, version);
    return CHUE_NOT_ON_KURJUN;
  }
  std::vector<CGorjunFileInfo>::iterator item = fi.begin();

  CDownloadFileManager *dm = new CDownloadFileManager(
      item->name(), str_vagrant_downloaded_path, item->size());
  dm->set_link(ipfs_download_url().arg(item->id(), item->name()));

  SilentInstaller *silent_installer = new SilentInstaller(this);
  silent_installer->init(file_dir, file_name, CC_VAGRANT);

  connect(dm, &CDownloadFileManager::download_progress_sig,
          [this](qint64 rec, qint64 total) {
            update_progress_sl(rec, total);
          });

  connect(dm, &CDownloadFileManager::finished,
          [this, silent_installer](bool success) {
            if (!success) {
              silent_installer->outputReceived(success, "undefined");
            } else {
              this->update_progress_sl(0,0);
              CNotificationObserver::Instance()->Info(
                  tr("Running installation scripts."),
                  DlgNotification::N_NO_ACTION);
              silent_installer->startWork();
            }
          });

  connect(silent_installer, &SilentInstaller::outputReceived, this,
          &CUpdaterComponentVAGRANT::install_finished_sl);

  connect(silent_installer, &SilentInstaller::outputReceived, dm,
          &CDownloadFileManager::deleteLater);
  dm->start_download();
  return CHUE_SUCCESS;
}