Commit 9ae3a603 authored by MikeSalmela's avatar MikeSalmela

Merge branch 'jb29667' into 'master'

[vault] add helper functions for running QProcesses. JB#29667

See merge request !12
parents c6643550 e19028e1
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
#include <qtaround/debug.hpp> #include <qtaround/debug.hpp>
#include <QString> #include <QString>
#include <QProcess>
#include <QDebug>
#include <QLoggingCategory>
namespace os = qtaround::os; namespace os = qtaround::os;
namespace error = qtaround::error; namespace error = qtaround::error;
...@@ -22,6 +25,8 @@ namespace util = qtaround::util; ...@@ -22,6 +25,8 @@ namespace util = qtaround::util;
namespace json = qtaround::json; namespace json = qtaround::json;
namespace debug = qtaround::debug; namespace debug = qtaround::debug;
Q_LOGGING_CATEGORY(lcBackup, "org.sailfishos.backup", QtWarningMsg)
namespace vault { namespace unit { namespace vault { namespace unit {
static const unsigned current_version = 1; static const unsigned current_version = 1;
...@@ -496,4 +501,30 @@ int execute(std::unique_ptr<sys::GetOpt>, QVariantMap const &info) ...@@ -496,4 +501,30 @@ int execute(std::unique_ptr<sys::GetOpt>, QVariantMap const &info)
return 0; return 0;
} }
int execute(QVariantMap const &info)
{
try {
Operation op(getopt(), info);
op.execute();
} catch (error::Error const &e) {
qCDebug(lcBackup) << e;
return 1;
}
return 0;
}
int runProcess(const QString &program, const QStringList &args)
{
QProcess ps;
ps.start(program, args);
ps.waitForFinished(-1);
if (ps.exitStatus() == QProcess::CrashExit || ps.exitCode() != 0) {
qCDebug(lcBackup) << ps.program() << "failed";
qCDebug(lcBackup) << ps.readAllStandardError();
qCDebug(lcBackup) << ps.readAllStandardOutput();
return 1;
}
return 0;
}
}} // namespace vault::unit }} // namespace vault::unit
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
*/ */
#include <memory> #include <memory>
#include <QString>
#include <QVariantMap> #include <QVariantMap>
namespace qtaround { namespace sys { class GetOpt; }} namespace qtaround { namespace sys { class GetOpt; }}
...@@ -21,6 +21,10 @@ options_uptr getopt(); ...@@ -21,6 +21,10 @@ options_uptr getopt();
int execute(options_uptr, QVariantMap const &info); int execute(options_uptr, QVariantMap const &info);
int execute(QVariantMap const &info);
int runProcess(const QString &program, const QStringList &args);
}} }}
#endif // _CUTES_UNIT_HPP_ #endif // _CUTES_UNIT_HPP_
Summary: Incremental backup/restore framework Summary: Incremental backup/restore framework
Name: vault Name: vault
Version: 1.0.0 Version: 1.0.1
Release: 1 Release: 1
License: LGPLv2.1 License: LGPLv2
Group: Development/Libraries Group: Development/Libraries
URL: https://git.sailfishos.org/mer-core/vault URL: https://git.sailfishos.org/mer-core/vault
Source0: %{name}-%{version}.tar.bz2 Source0: %{name}-%{version}.tar.bz2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment