From dc0d01fa7d6c78713521c1084636a9a801d03746 Mon Sep 17 00:00:00 2001 From: erkin97 Date: Thu, 1 Mar 2018 14:09:32 +0600 Subject: [PATCH 1/5] reworked parsing of paths #649, remote file system mutex #669 --- SubutaiControlCenter.pro | 2 +- commons/src/OsBranchConsts.cpp | 2 +- hub/forms/DlgTransferFile.cpp | 51 +++++++++++++++++++++++++++++++--- hub/forms/DlgTransferFile.h | 1 + hub/src/SystemCallWrapper.cpp | 3 +- main.cpp | 15 +--------- 6 files changed, 52 insertions(+), 22 deletions(-) diff --git a/SubutaiControlCenter.pro b/SubutaiControlCenter.pro index c8f5d07b..f293ef20 100644 --- a/SubutaiControlCenter.pro +++ b/SubutaiControlCenter.pro @@ -141,7 +141,7 @@ DEFINES += TRAY_VERSION=\\\"$$TRAY_VERSION\\\" GIT_BRANCH_STR = $$system(git rev-parse --abbrev-ref HEAD) DEFINES += GIT_BRANCH=\\\"$$GIT_BRANCH_STR\\\" -GBV=BT_DEV +GBV=BT_PROD equals(GIT_BRANCH_STR, "master") { GBV=BT_MASTER } diff --git a/commons/src/OsBranchConsts.cpp b/commons/src/OsBranchConsts.cpp index ca236e47..6b4f5993 100644 --- a/commons/src/OsBranchConsts.cpp +++ b/commons/src/OsBranchConsts.cpp @@ -168,7 +168,7 @@ template const QString& hub_kurjun_url_temp_internal(); return res; \ } -hub_kurjun_url_temp_internal_def(BT_PROD, "https://cdn.subutai.io:8338/kurjun/rest/%1&owner=jenkins") +hub_kurjun_url_temp_internal_def(BT_PROD, "https://cdn.subut.ai:8338/kurjun/rest/%1&owner=jenkins") hub_kurjun_url_temp_internal_def(BT_MASTER, "https://mastercdn.subutai.io:8338/kurjun/rest/%1&owner=jenkins") hub_kurjun_url_temp_internal_def(BT_DEV, "https://devcdn.subutai.io:8338/kurjun/rest/%1&owner=jenkins") diff --git a/hub/forms/DlgTransferFile.cpp b/hub/forms/DlgTransferFile.cpp index 06b531be..a74a13cd 100644 --- a/hub/forms/DlgTransferFile.cpp +++ b/hub/forms/DlgTransferFile.cpp @@ -627,8 +627,8 @@ void DlgTransferFile::add_file_local(const QFileInfo &fi) { void DlgTransferFile::add_file_remote(const QString &file_info) { // Parsing the string - QString new_file_info = file_info; - QStringList splitted = new_file_info.trimmed().replace(QRegExp(" +"), " ").split(" "); + QStringList splitted; + DlgTransferFile::parse_remote_file(file_info, splitted); if (splitted.size() < 9) return; @@ -674,9 +674,7 @@ void DlgTransferFile::refresh_button_local() { } void DlgTransferFile::refresh_button_remote() { - set_buttons_enabled(false); refresh_remote_file_system(); - set_buttons_enabled(true); } //////////////////////////////////////////////////////////////////////////////// @@ -697,6 +695,12 @@ void DlgTransferFile::refresh_local_file_system() { } void DlgTransferFile::refresh_remote_file_system() { + + qDebug() + << "Refresh remote file system" + << current_remote_dir; + + ui->btn_refresh_remote->setEnabled(false); ui->lbl_remote_files->setMovie(remote_movie); remote_movie->start(); @@ -718,9 +722,13 @@ void DlgTransferFile::refresh_remote_file_system() { void DlgTransferFile::output_from_remote_command(system_call_wrapper_error_t res, const QStringList &output) { for (QString file_info : output) { + qDebug() + << "files from remote: " + << file_info; add_file_remote(file_info); } remote_movie->stop(); + ui->btn_refresh_remote->setEnabled(true); if (res == SCWE_SUCCESS) { ui->lbl_remote_files->setStyleSheet(""); ui->lbl_remote_files->setText("Remote"); @@ -732,6 +740,41 @@ void DlgTransferFile::output_from_remote_command(system_call_wrapper_error_t res } //////////////////////////////////////////////////////////////////////////////////////// +void DlgTransferFile::parse_remote_file(const QString &file_info, QStringList &splitted){ + int counter = 0; + bool reading_file = false; + bool reading_file_name = false; + int number_strings_parsed = 0; + QString st = ""; + while(counter != file_info.size()){ + if(reading_file_name == true){ + st+=file_info[counter]; + } + else { + if(reading_file == true){ + if(file_info[counter] == ' '){ + reading_file = false; + splitted.push_back(st); + st=""; + number_strings_parsed++; + } + else st+=file_info[counter]; + } + else{ + if(file_info[counter] != ' '){ + reading_file = true; + st+=file_info[counter]; + if (number_strings_parsed == 8) + reading_file_name = true; + } + } + } + counter++; + } + if(reading_file == true) splitted.push_back(st); +} +//////////////////////////////////////////////////////////////////////////////////////// + DlgTransferFile::~DlgTransferFile() { delete ui; diff --git a/hub/forms/DlgTransferFile.h b/hub/forms/DlgTransferFile.h index 5c16fc64..25ba321f 100644 --- a/hub/forms/DlgTransferFile.h +++ b/hub/forms/DlgTransferFile.h @@ -374,6 +374,7 @@ class DlgTransferFile : public QDialog void addSSHKey(const QString &key); void addIPPort(const QString &ip, const QString &port); void addUser(const QString &user); + void parse_remote_file(const QString &file_info, QStringList &splitted); private: QMovie *local_movie; diff --git a/hub/src/SystemCallWrapper.cpp b/hub/src/SystemCallWrapper.cpp index 7fdd34bf..a6b9b9fc 100644 --- a/hub/src/SystemCallWrapper.cpp +++ b/hub/src/SystemCallWrapper.cpp @@ -207,7 +207,6 @@ std::pair CSystemCallWrapper::upload_f QString cmd = CSettingsManager::Instance().scp_path(); QStringList args; - CNotificationObserver::Instance()->Info(file_path, DlgNotification::N_NO_ACTION); args<< "-rp" << "-o StrictHostKeyChecking=no" << "-P" << ssh_info.first @@ -237,7 +236,7 @@ std::pair CSystemCallWrapper::download << "-P" << ssh_info.first << "-S" << CSettingsManager::Instance().ssh_path() << "-i" << ssh_info.second - << QString("%1@%2:%3").arg(remote_user, ip, remote_file_path) + << QString("%1@%2:\"%3\"").arg(remote_user, ip, remote_file_path) << local_destination; qDebug() << "ARGS=" << args; system_call_res_t res = ssystem_th(cmd, args, true, true, 97); diff --git a/main.cpp b/main.cpp index e901168d..9bb17640 100644 --- a/main.cpp +++ b/main.cpp @@ -86,7 +86,7 @@ main(int argc, char *argv[]) { } QCommandLineParser cmd_parser; - cmd_parser.setApplicationDescription(QObject::tr("This tray application should help users to work with hub")); + cmd_parser.setApplicationDescription(QObject::tr("This Control Center application should help users to work with hub")); QCommandLineOption log_level_opt("l", "Log level can be DEBUG (0), WARNING (1), CRITICAL (2), FATAL (3), INFO (4). Trace is most detailed logs.", "log_level", @@ -147,19 +147,6 @@ main(int argc, char *argv[]) { P2PController::Instance().init(); P2PStatus_checker::Instance().update_status(); - if (!CSystemCallWrapper::p2p_daemon_check()) { - CNotificationObserver::Error(QObject::tr("Can't operate without the p2p daemon. " - "Either change the path setting in Settings or install the daemon if it is not installed. " - "You can get the %1 daemon from here."). - arg(current_branch_name()).arg(p2p_package_url()), DlgNotification::N_SETTINGS); - - /*send signal about p2p_status *new feature* */ - if(CCommons::IsApplicationLaunchable(CSettingsManager::Instance().p2p_path())) - emit P2PStatus_checker::Instance().p2p_status(P2PStatus_checker::P2P_READY); - else - emit P2PStatus_checker::Instance().p2p_status(P2PStatus_checker::P2P_FAIL); - } - result = app.exec(); } while (0); } catch (std::exception& ge) { From 9fca2ab3b59719c20cd5ecb79e6c258d9d993013 Mon Sep 17 00:00:00 2001 From: erkin97 Date: Thu, 1 Mar 2018 14:32:05 +0600 Subject: [PATCH 2/5] corrected wrong date format to m/d/y --- hub/forms/DlgTransferFile.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hub/forms/DlgTransferFile.cpp b/hub/forms/DlgTransferFile.cpp index a74a13cd..35aaaad7 100644 --- a/hub/forms/DlgTransferFile.cpp +++ b/hub/forms/DlgTransferFile.cpp @@ -371,8 +371,7 @@ void DlgTransferFile::clear_files() { QString DlgTransferFile::parseDate(const QString &month, const QString &day, const QString &year_or_time) { QString result; - result.append(day); - result.append("/"); + static std::map month_converter { {"Jan", "01"}, {"Feb", "02"}, {"Mar", "03"}, {"Apr", "04"}, {"May", "05"}, {"Jun", "06"}, {"Jul", "07"}, {"Aug", "08"}, {"Sep", "09"}, {"Oct", "10"}, {"Nov", "11"}, {"Dec", "12"}, @@ -380,6 +379,10 @@ QString DlgTransferFile::parseDate(const QString &month, const QString &day, con if(month_converter.find(month) == month_converter.end()) result.append("01"); else result.append(month_converter[month]); result.append("/"); + + result.append(day); + result.append("/"); + if (year_or_time.contains(":")) result.append(QDate::currentDate().toString("yyyy")); else result.append(year_or_time); return result; @@ -456,7 +459,7 @@ void DlgTransferFile::add_file_to_file_system_tw(QTableWidget *file_system_tw, i file_system_tw->insertRow(row); QTableWidgetItem *wi_file_name; QTableWidgetItem *wi_file_size = new QTableWidgetItem(QString::number(file.fileSize())); - QTableWidgetItem *wi_file_modified = new QTableWidgetItem(file.created().toString("dd/mm/yyyy")); + QTableWidgetItem *wi_file_modified = new QTableWidgetItem(file.created().toString("MM/dd/yyyy")); QTableWidgetItem *wi_file_path = new QTableWidgetItem(file.filePath()); if (file.fileType() == FILE_TYPE_DIRECTORY) wi_file_name = new QTableWidgetItem(directory_icon, file.fileName()); else wi_file_name = new QTableWidgetItem(file_icon, file.fileName()); @@ -648,7 +651,7 @@ void DlgTransferFile::add_file_remote(const QString &file_info) { file_path.chop(1); // remove last character, which is `*` QDateTime created = QDateTime::fromString(parseDate(file_month, file_day, file_year_or_time), - "dd/mm/yyyy"); + "MM/d/yyyy"); OneFile remote_file(file_name, file_path, From 49c4dbe0da946f53cc6e3dc2fa24b55ab8eb48e4 Mon Sep 17 00:00:00 2001 From: erkin97 Date: Thu, 1 Mar 2018 15:14:23 +0600 Subject: [PATCH 3/5] correct links --- SubutaiControlCenter.pro | 2 +- commons/src/OsBranchConsts.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SubutaiControlCenter.pro b/SubutaiControlCenter.pro index f293ef20..c8f5d07b 100644 --- a/SubutaiControlCenter.pro +++ b/SubutaiControlCenter.pro @@ -141,7 +141,7 @@ DEFINES += TRAY_VERSION=\\\"$$TRAY_VERSION\\\" GIT_BRANCH_STR = $$system(git rev-parse --abbrev-ref HEAD) DEFINES += GIT_BRANCH=\\\"$$GIT_BRANCH_STR\\\" -GBV=BT_PROD +GBV=BT_DEV equals(GIT_BRANCH_STR, "master") { GBV=BT_MASTER } diff --git a/commons/src/OsBranchConsts.cpp b/commons/src/OsBranchConsts.cpp index 6b4f5993..ca236e47 100644 --- a/commons/src/OsBranchConsts.cpp +++ b/commons/src/OsBranchConsts.cpp @@ -168,7 +168,7 @@ template const QString& hub_kurjun_url_temp_internal(); return res; \ } -hub_kurjun_url_temp_internal_def(BT_PROD, "https://cdn.subut.ai:8338/kurjun/rest/%1&owner=jenkins") +hub_kurjun_url_temp_internal_def(BT_PROD, "https://cdn.subutai.io:8338/kurjun/rest/%1&owner=jenkins") hub_kurjun_url_temp_internal_def(BT_MASTER, "https://mastercdn.subutai.io:8338/kurjun/rest/%1&owner=jenkins") hub_kurjun_url_temp_internal_def(BT_DEV, "https://devcdn.subutai.io:8338/kurjun/rest/%1&owner=jenkins") From a8374faec72b47d22df9c22592cdf646ca4316fb Mon Sep 17 00:00:00 2001 From: erkin97 Date: Thu, 1 Mar 2018 18:06:44 +0600 Subject: [PATCH 4/5] remove ssh_key notification --- hub/src/HubController.cpp | 1 - hub/src/SystemCallWrapper.cpp | 2 -- 2 files changed, 3 deletions(-) diff --git a/hub/src/HubController.cpp b/hub/src/HubController.cpp index 9a8e70d2..027a9b1d 100644 --- a/hub/src/HubController.cpp +++ b/hub/src/HubController.cpp @@ -367,7 +367,6 @@ ssh_desktop_launch_error_t CHubController::ssh_to_container_internal(const CEnvi ssh_desktop_launch_error_t CHubController::ssh_to_container(const CEnvironment &env, const CHubContainer &cont) { QString key = get_env_key(env.id()); - CNotificationObserver::Instance()->Info(key, DlgNotification::N_NO_ACTION); return ssh_to_container_internal(env, cont, key); } diff --git a/hub/src/SystemCallWrapper.cpp b/hub/src/SystemCallWrapper.cpp index a6b9b9fc..84446395 100644 --- a/hub/src/SystemCallWrapper.cpp +++ b/hub/src/SystemCallWrapper.cpp @@ -595,8 +595,6 @@ system_call_wrapper_error_t run_sshkey_in_terminal_internal >(co .arg(port); if (!key.isEmpty()) { - CNotificationObserver::Instance()->Info( - QObject::tr("Using %1 ssh key").arg(key), DlgNotification::N_NO_ACTION); str_command += QString(" -i \"%1\" ").arg(key); } From c375967510b8393742771c488b67591bc017def3 Mon Sep 17 00:00:00 2001 From: erkin97 Date: Thu, 1 Mar 2018 18:11:27 +0600 Subject: [PATCH 5/5] version 6.7.1 --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index f0e13c50..06a76599 100644 --- a/version +++ b/version @@ -1 +1 @@ -6.7.0 +6.7.1