mirror of
https://github.com/arcan1s/queued.git
synced 2025-04-25 07:57:18 +00:00
some work on queuedctl
This commit is contained in:
parent
80c6f977d7
commit
9931204837
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -53,7 +53,6 @@ int main(int argc, char *argv[])
|
|||||||
::daemon(0, 0);
|
::daemon(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
app.setApplicationName(NAME);
|
app.setApplicationName(NAME);
|
||||||
app.setApplicationVersion(VERSION);
|
app.setApplicationVersion(VERSION);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -33,10 +33,10 @@
|
|||||||
bool QueuedCoreAdaptor::auth(const QString &_token)
|
bool QueuedCoreAdaptor::auth(const QString &_token)
|
||||||
{
|
{
|
||||||
QVariantList args = {_token};
|
QVariantList args = {_token};
|
||||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
return sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||||
QueuedConfig::DBUS_OBJECT_PATH,
|
QueuedConfig::DBUS_OBJECT_PATH,
|
||||||
QueuedConfig::DBUS_SERVICE, "/TryAuth",
|
QueuedConfig::DBUS_SERVICE, "TryAuth", args)
|
||||||
args))
|
.at(0)
|
||||||
.toBool();
|
.toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,9 +49,10 @@ QString QueuedCoreAdaptor::auth(const QString &_name, const QString &_password)
|
|||||||
qCDebug(LOG_DBUS) << "Auth user" << _name;
|
qCDebug(LOG_DBUS) << "Auth user" << _name;
|
||||||
|
|
||||||
QVariantList args = {_name, _password};
|
QVariantList args = {_name, _password};
|
||||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
return sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||||
QueuedConfig::DBUS_OBJECT_PATH,
|
QueuedConfig::DBUS_OBJECT_PATH,
|
||||||
QueuedConfig::DBUS_SERVICE, "/Auth", args))
|
QueuedConfig::DBUS_SERVICE, "Auth", args)
|
||||||
|
.at(0)
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,11 +66,12 @@ bool QueuedCoreAdaptor::sendOptionEdit(const QString &_key,
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_DBUS) << "Edit option" << _key << "to" << _value;
|
qCDebug(LOG_DBUS) << "Edit option" << _key << "to" << _value;
|
||||||
|
|
||||||
QVariantList args = {_key, _value, _token};
|
QVariantList args
|
||||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
= {_key, QVariant::fromValue(QDBusVariant(_value)), _token};
|
||||||
QueuedConfig::DBUS_OBJECT_PATH,
|
return sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||||
QueuedConfig::DBUS_SERVICE, "/OptionEdit",
|
QueuedConfig::DBUS_OBJECT_PATH,
|
||||||
args))
|
QueuedConfig::DBUS_SERVICE, "OptionEdit", args)
|
||||||
|
.at(0)
|
||||||
.toBool();
|
.toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,10 +85,10 @@ bool QueuedCoreAdaptor::sendPluginAdd(const QString &_plugin,
|
|||||||
qCDebug(LOG_DBUS) << "Add plugin" << _plugin;
|
qCDebug(LOG_DBUS) << "Add plugin" << _plugin;
|
||||||
|
|
||||||
QVariantList args = {_plugin, _token};
|
QVariantList args = {_plugin, _token};
|
||||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
return sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||||
QueuedConfig::DBUS_OBJECT_PATH,
|
QueuedConfig::DBUS_OBJECT_PATH,
|
||||||
QueuedConfig::DBUS_SERVICE, "/PluginAdd",
|
QueuedConfig::DBUS_SERVICE, "PluginAdd", args)
|
||||||
args))
|
.at(0)
|
||||||
.toBool();
|
.toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,10 +102,10 @@ bool QueuedCoreAdaptor::sendPluginRemove(const QString &_plugin,
|
|||||||
qCDebug(LOG_DBUS) << "Remove plugin" << _plugin;
|
qCDebug(LOG_DBUS) << "Remove plugin" << _plugin;
|
||||||
|
|
||||||
QVariantList args = {_plugin, _token};
|
QVariantList args = {_plugin, _token};
|
||||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
return sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||||
QueuedConfig::DBUS_OBJECT_PATH,
|
QueuedConfig::DBUS_OBJECT_PATH,
|
||||||
QueuedConfig::DBUS_SERVICE, "/PluginRemove",
|
QueuedConfig::DBUS_SERVICE, "PluginRemove", args)
|
||||||
args))
|
.at(0)
|
||||||
.toBool();
|
.toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,10 +130,10 @@ long long QueuedCoreAdaptor::sendTaskAdd(
|
|||||||
limits.gpumemory,
|
limits.gpumemory,
|
||||||
limits.storage,
|
limits.storage,
|
||||||
_token};
|
_token};
|
||||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
return sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||||
QueuedConfig::DBUS_OBJECT_PATH,
|
QueuedConfig::DBUS_OBJECT_PATH,
|
||||||
QueuedConfig::DBUS_SERVICE, "/TaskAdd",
|
QueuedConfig::DBUS_SERVICE, "TaskAdd", args)
|
||||||
args))
|
.at(0)
|
||||||
.toLongLong();
|
.toLongLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,10 +163,10 @@ bool QueuedCoreAdaptor::sendTaskEdit(
|
|||||||
limits.gpumemory,
|
limits.gpumemory,
|
||||||
limits.storage,
|
limits.storage,
|
||||||
_token};
|
_token};
|
||||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
return sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||||
QueuedConfig::DBUS_OBJECT_PATH,
|
QueuedConfig::DBUS_OBJECT_PATH,
|
||||||
QueuedConfig::DBUS_SERVICE, "/TaskEdit",
|
QueuedConfig::DBUS_SERVICE, "TaskEdit", args)
|
||||||
args))
|
.at(0)
|
||||||
.toBool();
|
.toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,10 +180,10 @@ bool QueuedCoreAdaptor::sendTaskStart(const long long _id,
|
|||||||
qCDebug(LOG_DBUS) << "Start task" << _id;
|
qCDebug(LOG_DBUS) << "Start task" << _id;
|
||||||
|
|
||||||
QVariantList args = {_id, _token};
|
QVariantList args = {_id, _token};
|
||||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
return sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||||
QueuedConfig::DBUS_OBJECT_PATH,
|
QueuedConfig::DBUS_OBJECT_PATH,
|
||||||
QueuedConfig::DBUS_SERVICE, "/TaskStart",
|
QueuedConfig::DBUS_SERVICE, "TaskStart", args)
|
||||||
args))
|
.at(0)
|
||||||
.toBool();
|
.toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,10 +196,10 @@ bool QueuedCoreAdaptor::sendTaskStop(const long long _id, const QString &_token)
|
|||||||
qCDebug(LOG_DBUS) << "Stop task" << _id;
|
qCDebug(LOG_DBUS) << "Stop task" << _id;
|
||||||
|
|
||||||
QVariantList args = {_id, _token};
|
QVariantList args = {_id, _token};
|
||||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
return sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||||
QueuedConfig::DBUS_OBJECT_PATH,
|
QueuedConfig::DBUS_OBJECT_PATH,
|
||||||
QueuedConfig::DBUS_SERVICE, "/TaskStop",
|
QueuedConfig::DBUS_SERVICE, "TaskStop", args)
|
||||||
args))
|
.at(0)
|
||||||
.toBool();
|
.toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,10 +224,10 @@ long long QueuedCoreAdaptor::sendUserAdd(
|
|||||||
limits.gpumemory,
|
limits.gpumemory,
|
||||||
limits.storage,
|
limits.storage,
|
||||||
_token};
|
_token};
|
||||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
return sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||||
QueuedConfig::DBUS_OBJECT_PATH,
|
QueuedConfig::DBUS_OBJECT_PATH,
|
||||||
QueuedConfig::DBUS_SERVICE, "/UserAdd",
|
QueuedConfig::DBUS_SERVICE, "UserAdd", args)
|
||||||
args))
|
.at(0)
|
||||||
.toLongLong();
|
.toLongLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,10 +252,10 @@ bool QueuedCoreAdaptor::sendUserEdit(
|
|||||||
limits.gpumemory,
|
limits.gpumemory,
|
||||||
limits.storage,
|
limits.storage,
|
||||||
_token};
|
_token};
|
||||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
return sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||||
QueuedConfig::DBUS_OBJECT_PATH,
|
QueuedConfig::DBUS_OBJECT_PATH,
|
||||||
QueuedConfig::DBUS_SERVICE, "/UserEdit",
|
QueuedConfig::DBUS_SERVICE, "UserEdit", args)
|
||||||
args))
|
.at(0)
|
||||||
.toBool();
|
.toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,10 +271,10 @@ bool QueuedCoreAdaptor::sendUserPermissionAdd(
|
|||||||
<< "to" << _id;
|
<< "to" << _id;
|
||||||
|
|
||||||
QVariantList args = {_id, static_cast<uint>(_permission), _token};
|
QVariantList args = {_id, static_cast<uint>(_permission), _token};
|
||||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
return sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||||
QueuedConfig::DBUS_OBJECT_PATH,
|
QueuedConfig::DBUS_OBJECT_PATH,
|
||||||
QueuedConfig::DBUS_SERVICE,
|
QueuedConfig::DBUS_SERVICE, "UserPermissionAdd", args)
|
||||||
"/UserPermissionAdd", args))
|
.at(0)
|
||||||
.toBool();
|
.toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,10 +290,10 @@ bool QueuedCoreAdaptor::sendUserPermissionRemove(
|
|||||||
<< "from" << _id;
|
<< "from" << _id;
|
||||||
|
|
||||||
QVariantList args = {_id, static_cast<uint>(_permission), _token};
|
QVariantList args = {_id, static_cast<uint>(_permission), _token};
|
||||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
return sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||||
QueuedConfig::DBUS_OBJECT_PATH,
|
QueuedConfig::DBUS_OBJECT_PATH,
|
||||||
QueuedConfig::DBUS_SERVICE,
|
QueuedConfig::DBUS_SERVICE, "UserPermissionRemove", args)
|
||||||
"/UserPermissionRemove", args))
|
.at(0)
|
||||||
.toBool();
|
.toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,9 +306,10 @@ QVariant QueuedCoreAdaptor::getOption(const QString &_property)
|
|||||||
qCDebug(LOG_DBUS) << "Get option" << _property;
|
qCDebug(LOG_DBUS) << "Get option" << _property;
|
||||||
|
|
||||||
QVariantList args = {_property};
|
QVariantList args = {_property};
|
||||||
return toNativeType(sendRequest(
|
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||||
QueuedConfig::DBUS_SERVICE, QueuedConfig::DBUS_PROPERTY_PATH,
|
QueuedConfig::DBUS_PROPERTY_PATH,
|
||||||
QueuedConfig::DBUS_SERVICE, "/Option", args));
|
QueuedConfig::DBUS_SERVICE, "Option", args)
|
||||||
|
.at(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -321,7 +324,8 @@ QVariant QueuedCoreAdaptor::getTask(const long long _id,
|
|||||||
QVariantList args = {_id, _property};
|
QVariantList args = {_id, _property};
|
||||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||||
QueuedConfig::DBUS_PROPERTY_PATH,
|
QueuedConfig::DBUS_PROPERTY_PATH,
|
||||||
QueuedConfig::DBUS_SERVICE, "/Task", args));
|
QueuedConfig::DBUS_SERVICE, "Task", args)
|
||||||
|
.at(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,7 +340,8 @@ QVariant QueuedCoreAdaptor::getUser(const long long _id,
|
|||||||
QVariantList args = {_id, _property};
|
QVariantList args = {_id, _property};
|
||||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||||
QueuedConfig::DBUS_PROPERTY_PATH,
|
QueuedConfig::DBUS_PROPERTY_PATH,
|
||||||
QueuedConfig::DBUS_SERVICE, "/User", args));
|
QueuedConfig::DBUS_SERVICE, "User", args)
|
||||||
|
.at(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -64,7 +64,6 @@ QString QueuedctlAuth::getToken(const QString &_cache, const QString &_user)
|
|||||||
|
|
||||||
void QueuedctlAuth::parser(QCommandLineParser &_parser)
|
void QueuedctlAuth::parser(QCommandLineParser &_parser)
|
||||||
{
|
{
|
||||||
_parser.clearPositionalArguments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
124
sources/queuedctl/src/QueuedctlCommon.cpp
Normal file
124
sources/queuedctl/src/QueuedctlCommon.cpp
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
*
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "QueuedctlCommon.h"
|
||||||
|
|
||||||
|
#include <queued/Queued.h>
|
||||||
|
|
||||||
|
#include "QueuedctlAuth.h"
|
||||||
|
#include "QueuedctlOption.h"
|
||||||
|
#include "QueuedctlTask.h"
|
||||||
|
|
||||||
|
|
||||||
|
void QueuedctlCommon::checkArgs(const QStringList &_args, const int _count,
|
||||||
|
QCommandLineParser &_parser)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_APP) << "Check args count" << _args << _count;
|
||||||
|
|
||||||
|
if (_args.count() != _count) {
|
||||||
|
qWarning() << "Invalid command";
|
||||||
|
_parser.showHelp(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QueuedctlCommon::preprocess(const QStringList &_args,
|
||||||
|
QCommandLineParser &_parser)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_APP) << "Preprocess command" << _args;
|
||||||
|
|
||||||
|
QString command = _args.isEmpty() ? QString() : _args.first();
|
||||||
|
// HACK: workaround to show valid help message
|
||||||
|
_parser.addPositionalArgument(command, "Command to execute.");
|
||||||
|
|
||||||
|
if (command == "auth")
|
||||||
|
QueuedctlAuth::parser(_parser);
|
||||||
|
else if (command == "option-get")
|
||||||
|
QueuedctlOption::parserGet(_parser);
|
||||||
|
else if (command == "option-set")
|
||||||
|
QueuedctlOption::parserSet(_parser);
|
||||||
|
else if (command == "task-add")
|
||||||
|
QueuedctlTask::parserAdd(_parser);
|
||||||
|
else if (command == "task-get")
|
||||||
|
QueuedctlTask::parserGet(_parser);
|
||||||
|
else if (command == "task-set")
|
||||||
|
QueuedctlTask::parserSet(_parser);
|
||||||
|
else if (command == "user-add") {
|
||||||
|
} else if (command == "user-get") {
|
||||||
|
} else if (command == "user-set") {
|
||||||
|
} else if (!command.isEmpty())
|
||||||
|
checkArgs(_args, -1, _parser);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QueuedctlCommon::print(QueuedctlResult &_result)
|
||||||
|
{
|
||||||
|
if (!_result.status)
|
||||||
|
qInfo() << "Subprocess returns error";
|
||||||
|
if (!_result.output.isEmpty())
|
||||||
|
QDebug(QtMsgType::QtInfoMsg).noquote() << _result.output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QueuedctlCommon::QueuedctlResult
|
||||||
|
QueuedctlCommon::process(QCommandLineParser &_parser, const QString &_cache,
|
||||||
|
const QString &_user)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_APP) << "Process command with args"
|
||||||
|
<< "using auth" << _cache << _user;
|
||||||
|
|
||||||
|
QueuedctlResult result;
|
||||||
|
QStringList args = _parser.positionalArguments();
|
||||||
|
QString command = args.isEmpty() ? QString() : args.first();
|
||||||
|
|
||||||
|
if (command == "auth") {
|
||||||
|
checkArgs(args, 1, _parser);
|
||||||
|
QString token = QueuedctlAuth::auth(_user);
|
||||||
|
result.status = !token.isEmpty();
|
||||||
|
if (result.status)
|
||||||
|
QueuedctlAuth::setToken(token, _cache);
|
||||||
|
} else if (command == "option-get") {
|
||||||
|
checkArgs(args, 2, _parser);
|
||||||
|
QVariant value = QueuedctlOption::getOption(args.at(1));
|
||||||
|
result.status = value.isValid();
|
||||||
|
result.output = value.toString();
|
||||||
|
} else if (command == "option-set") {
|
||||||
|
checkArgs(args, 3, _parser);
|
||||||
|
QString token = QueuedctlAuth::getToken(_cache, _user);
|
||||||
|
result.status
|
||||||
|
= QueuedctlOption::editOption(args.at(1), args.at(2), token);
|
||||||
|
if (result.status)
|
||||||
|
result.output
|
||||||
|
= QString("Option %1 set to %2").arg(args.at(1), args.at(2));
|
||||||
|
else
|
||||||
|
result.output = QString("Could not set option %1 to %2")
|
||||||
|
.arg(args.at(1), args.at(2));
|
||||||
|
} else if (command == "task-get") {
|
||||||
|
checkArgs(args, 3, _parser);
|
||||||
|
QVariant value
|
||||||
|
= QueuedctlTask::getTask(args.at(1).toLongLong(), args.at(2));
|
||||||
|
result.status = value.isValid();
|
||||||
|
result.output = value.toString();
|
||||||
|
} else if (command == "task-set") {
|
||||||
|
checkArgs(args, 2, _parser);
|
||||||
|
QString token = QueuedctlAuth::getToken(_cache, _user);
|
||||||
|
auto definitions = QueuedctlTask::getDefinitions(_parser);
|
||||||
|
result.status = QueuedctlTask::setTask(args.at(1).toLongLong(),
|
||||||
|
definitions, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
38
sources/queuedctl/src/QueuedctlCommon.h
Normal file
38
sources/queuedctl/src/QueuedctlCommon.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
*
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef QUEUEDCTLCOMMON_H
|
||||||
|
#define QUEUEDCTLCOMMON_H
|
||||||
|
|
||||||
|
#include <QCommandLineParser>
|
||||||
|
|
||||||
|
|
||||||
|
namespace QueuedctlCommon
|
||||||
|
{
|
||||||
|
typedef struct {
|
||||||
|
bool status = false;
|
||||||
|
QString output;
|
||||||
|
} QueuedctlResult;
|
||||||
|
void checkArgs(const QStringList &_args, const int _count,
|
||||||
|
QCommandLineParser &_parser);
|
||||||
|
void preprocess(const QStringList &_args, QCommandLineParser &_parser);
|
||||||
|
void print(QueuedctlResult &_result);
|
||||||
|
QueuedctlResult process(QCommandLineParser &_parser, const QString &_cache,
|
||||||
|
const QString &_user);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* QUEUEDCTLCOMMON_H */
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -18,22 +18,32 @@
|
|||||||
|
|
||||||
#include <queued/Queued.h>
|
#include <queued/Queued.h>
|
||||||
|
|
||||||
#include "QueuedctlAuth.h"
|
|
||||||
|
|
||||||
|
|
||||||
bool QueuedctlOption::editOption(const QString &_option, const QVariant &_value,
|
bool QueuedctlOption::editOption(const QString &_option, const QVariant &_value,
|
||||||
const QString &_cache, const QString &_user)
|
const QString &_token)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_APP) << "Edit option" << _option << "to" << _value;
|
qCDebug(LOG_APP) << "Edit option" << _option << "to" << _value;
|
||||||
|
|
||||||
QString token = QueuedctlAuth::getToken(_cache, _user);
|
return QueuedCoreAdaptor::sendOptionEdit(_option, _value, _token);
|
||||||
return QueuedCoreAdaptor::sendOptionEdit(_option, _value, token);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QueuedctlOption::parser(QCommandLineParser &_parser)
|
QVariant QueuedctlOption::getOption(const QString &_option)
|
||||||
{
|
{
|
||||||
_parser.clearPositionalArguments();
|
qCDebug(LOG_APP) << "Get option" << _option;
|
||||||
_parser.addPositionalArgument("option", "Option name.");
|
|
||||||
_parser.addPositionalArgument("value", "Option value.");
|
return QueuedCoreAdaptor::getOption(_option);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QueuedctlOption::parserGet(QCommandLineParser &_parser)
|
||||||
|
{
|
||||||
|
_parser.addPositionalArgument("option", "Option name.", "<option>");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QueuedctlOption::parserSet(QCommandLineParser &_parser)
|
||||||
|
{
|
||||||
|
_parser.addPositionalArgument("option", "Option name.", "<option>");
|
||||||
|
_parser.addPositionalArgument("value", "Option value.", "<value>");
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -23,8 +23,10 @@
|
|||||||
namespace QueuedctlOption
|
namespace QueuedctlOption
|
||||||
{
|
{
|
||||||
bool editOption(const QString &_option, const QVariant &_value,
|
bool editOption(const QString &_option, const QVariant &_value,
|
||||||
const QString &_cache, const QString &_user);
|
const QString &_token);
|
||||||
void parser(QCommandLineParser &_parser);
|
QVariant getOption(const QString &_option);
|
||||||
|
void parserGet(QCommandLineParser &_parser);
|
||||||
|
void parserSet(QCommandLineParser &_parser);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
188
sources/queuedctl/src/QueuedctlTask.cpp
Normal file
188
sources/queuedctl/src/QueuedctlTask.cpp
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
*
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "QueuedctlTask.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
#include <queued/Queued.h>
|
||||||
|
|
||||||
|
|
||||||
|
QueuedProcess::QueuedProcessDefinitions
|
||||||
|
QueuedctlTask::getDefinitions(const QCommandLineParser &_parser)
|
||||||
|
{
|
||||||
|
QueuedProcess::QueuedProcessDefinitions definitions;
|
||||||
|
|
||||||
|
definitions.command = _parser.value("program");
|
||||||
|
std::for_each(_parser.values("argument").cbegin(),
|
||||||
|
_parser.values("argument").cend(),
|
||||||
|
[&definitions](const QString &arg) {
|
||||||
|
if (!arg.isEmpty())
|
||||||
|
definitions.arguments += arg;
|
||||||
|
});
|
||||||
|
definitions.endTime
|
||||||
|
= QDateTime::fromString(_parser.value("stop"), Qt::ISODate);
|
||||||
|
definitions.gid = _parser.value("gid").toUInt();
|
||||||
|
definitions.nice = _parser.value("nice").toUInt();
|
||||||
|
definitions.startTime
|
||||||
|
= QDateTime::fromString(_parser.value("start"), Qt::ISODate);
|
||||||
|
definitions.uid = _parser.value("uid").toUInt();
|
||||||
|
definitions.user = _parser.value("task-user").toLongLong();
|
||||||
|
definitions.workingDirectory = _parser.value("directory");
|
||||||
|
// limits now
|
||||||
|
QueuedLimits::Limits limits(
|
||||||
|
_parser.value("limit-cpu").toLongLong(),
|
||||||
|
_parser.value("limit-gpu").toLongLong(),
|
||||||
|
QueuedLimits::convertMemory(_parser.value("limit-memory")),
|
||||||
|
QueuedLimits::convertMemory(_parser.value("limit-gpumemory")),
|
||||||
|
QueuedLimits::convertMemory(_parser.value("limit-storage")));
|
||||||
|
definitions.limits = limits.toString();
|
||||||
|
|
||||||
|
return definitions;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant QueuedctlTask::getTask(const long long _id, const QString &_property)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_APP) << "Get property" << _property << "from task" << _id;
|
||||||
|
|
||||||
|
return QueuedCoreAdaptor::getTask(_id, _property);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QueuedctlTask::parserAdd(QCommandLineParser &_parser)
|
||||||
|
{
|
||||||
|
_parser.addPositionalArgument("program", "Command line.", "<program>");
|
||||||
|
|
||||||
|
// command line arguments
|
||||||
|
QCommandLineOption argumentOption(QStringList() << "a"
|
||||||
|
<< "argument",
|
||||||
|
"Command line argument.", "argument", "");
|
||||||
|
_parser.addOption(argumentOption);
|
||||||
|
// working directory
|
||||||
|
QCommandLineOption directoryOption(QStringList() << "d"
|
||||||
|
<< "directory",
|
||||||
|
"Command working directory.",
|
||||||
|
"directory", QDir::currentPath());
|
||||||
|
_parser.addOption(directoryOption);
|
||||||
|
// user
|
||||||
|
// TODO grab used user ID
|
||||||
|
QCommandLineOption userOption("task-user", "Task user.", "task-user", "0");
|
||||||
|
_parser.addOption(userOption);
|
||||||
|
// nice
|
||||||
|
QCommandLineOption niceOption("nice", "Task nice level.", "nice", "0");
|
||||||
|
_parser.addOption(niceOption);
|
||||||
|
// cpu limit
|
||||||
|
QCommandLineOption cpuOption("limit-cpu", "Task CPU limit.", "limit-cpu",
|
||||||
|
"0");
|
||||||
|
_parser.addOption(cpuOption);
|
||||||
|
// gpu limit
|
||||||
|
QCommandLineOption gpuOption("limit-gpu", "Task GPU limit.", "limit-gpu",
|
||||||
|
"0");
|
||||||
|
_parser.addOption(gpuOption);
|
||||||
|
// memory limit
|
||||||
|
QCommandLineOption memoryOption("limit-memory", "Task memory limit.",
|
||||||
|
"limit-memory", "0");
|
||||||
|
_parser.addOption(memoryOption);
|
||||||
|
// gpu memory limit
|
||||||
|
QCommandLineOption gpumemoryOption(
|
||||||
|
"limit-gpumemory", "Task GPU memory limit.", "limit-gpumemory", "0");
|
||||||
|
_parser.addOption(gpumemoryOption);
|
||||||
|
// storage limit
|
||||||
|
QCommandLineOption storageOption("limit-storage", "Task storage limit.",
|
||||||
|
"limit-storage", "0");
|
||||||
|
_parser.addOption(storageOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QueuedctlTask::parserGet(QCommandLineParser &_parser)
|
||||||
|
{
|
||||||
|
_parser.addPositionalArgument("id", "Task ID.", "<id>");
|
||||||
|
_parser.addPositionalArgument("property", "Task property name.",
|
||||||
|
"<property>");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QueuedctlTask::parserSet(QCommandLineParser &_parser)
|
||||||
|
{
|
||||||
|
_parser.addPositionalArgument("id", "Task ID.", "<id>");
|
||||||
|
|
||||||
|
// command line
|
||||||
|
QCommandLineOption commandOption(QStringList() << "p"
|
||||||
|
<< "program",
|
||||||
|
"Command line.", "program", "");
|
||||||
|
_parser.addOption(commandOption);
|
||||||
|
// command line arguments
|
||||||
|
QCommandLineOption argumentOption(QStringList() << "a"
|
||||||
|
<< "argument",
|
||||||
|
"Command line argument.", "argument", "");
|
||||||
|
_parser.addOption(argumentOption);
|
||||||
|
// working directory
|
||||||
|
QCommandLineOption directoryOption(QStringList() << "d"
|
||||||
|
<< "directory",
|
||||||
|
"Command working directory.",
|
||||||
|
"directory", "");
|
||||||
|
_parser.addOption(directoryOption);
|
||||||
|
// user
|
||||||
|
QCommandLineOption userOption("task-user", "Task user.", "task-user", "0");
|
||||||
|
_parser.addOption(userOption);
|
||||||
|
// nice
|
||||||
|
QCommandLineOption niceOption("nice", "Task nice level.", "nice", "0");
|
||||||
|
_parser.addOption(niceOption);
|
||||||
|
// uid
|
||||||
|
QCommandLineOption uidOption("uid", "UID.", "uid", "0");
|
||||||
|
_parser.addOption(uidOption);
|
||||||
|
// gid
|
||||||
|
QCommandLineOption gidOption("gid", "GID.", "gid", "0");
|
||||||
|
_parser.addOption(gidOption);
|
||||||
|
// start
|
||||||
|
QCommandLineOption startOption("start", "Task start time.", "start", "");
|
||||||
|
_parser.addOption(startOption);
|
||||||
|
// stop
|
||||||
|
QCommandLineOption stopOption("stop", "Task stop time.", "stop", "");
|
||||||
|
_parser.addOption(stopOption);
|
||||||
|
// cpu limit
|
||||||
|
QCommandLineOption cpuOption("limit-cpu", "Task CPU limit.", "limit-cpu",
|
||||||
|
"-1");
|
||||||
|
_parser.addOption(cpuOption);
|
||||||
|
// gpu limit
|
||||||
|
QCommandLineOption gpuOption("limit-gpu", "Task GPU limit.", "limit-gpu",
|
||||||
|
"-1");
|
||||||
|
_parser.addOption(gpuOption);
|
||||||
|
// memory limit
|
||||||
|
QCommandLineOption memoryOption("limit-memory", "Task memory limit.",
|
||||||
|
"limit-memory", "-1");
|
||||||
|
_parser.addOption(memoryOption);
|
||||||
|
// gpu memory limit
|
||||||
|
QCommandLineOption gpumemoryOption(
|
||||||
|
"limit-gpumemory", "Task GPU memory limit.", "limit-gpumemory", "-1");
|
||||||
|
_parser.addOption(gpumemoryOption);
|
||||||
|
// storage limit
|
||||||
|
QCommandLineOption storageOption("limit-storage", "Task storage limit.",
|
||||||
|
"limit-storage", "-1");
|
||||||
|
_parser.addOption(storageOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool QueuedctlTask::setTask(
|
||||||
|
const long long _id,
|
||||||
|
const QueuedProcess::QueuedProcessDefinitions &_definitions,
|
||||||
|
const QString &_token)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_APP) << "Edit task" << _id;
|
||||||
|
|
||||||
|
return QueuedCoreAdaptor::sendTaskEdit(_id, _definitions, _token);
|
||||||
|
}
|
39
sources/queuedctl/src/QueuedctlTask.h
Normal file
39
sources/queuedctl/src/QueuedctlTask.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
*
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef QUEUEDCTLTASK_H
|
||||||
|
#define QUEUEDCTLTASK_H
|
||||||
|
|
||||||
|
#include <QCommandLineParser>
|
||||||
|
|
||||||
|
#include <queued/QueuedProcess.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace QueuedctlTask
|
||||||
|
{
|
||||||
|
QueuedProcess::QueuedProcessDefinitions
|
||||||
|
getDefinitions(const QCommandLineParser &_parser);
|
||||||
|
QVariant getTask(const long long _id, const QString &_property);
|
||||||
|
void parserAdd(QCommandLineParser &_parser);
|
||||||
|
void parserGet(QCommandLineParser &_parser);
|
||||||
|
void parserSet(QCommandLineParser &_parser);
|
||||||
|
bool setTask(const long long _id,
|
||||||
|
const QueuedProcess::QueuedProcessDefinitions &_definitions,
|
||||||
|
const QString &_token);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* QUEUEDCTLTASK_H */
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Evgeniy Alekseev
|
* Copyright (c) 2017 Evgeniy Alekseev
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -19,8 +19,7 @@
|
|||||||
|
|
||||||
#include <queued/Queued.h>
|
#include <queued/Queued.h>
|
||||||
|
|
||||||
#include "QueuedctlAuth.h"
|
#include "QueuedctlCommon.h"
|
||||||
#include "QueuedctlOption.h"
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -64,31 +63,14 @@ int main(int argc, char *argv[])
|
|||||||
"user", ::getlogin());
|
"user", ::getlogin());
|
||||||
parser.addOption(userOption);
|
parser.addOption(userOption);
|
||||||
|
|
||||||
parser.addPositionalArgument("command", "Command to execute.");
|
parser.addPositionalArgument("command", "Command to execute.", "<command>");
|
||||||
|
|
||||||
// pre-parse
|
// pre-parse
|
||||||
parser.parse(QCoreApplication::arguments());
|
parser.parse(QCoreApplication::arguments());
|
||||||
QStringList args = parser.positionalArguments();
|
QStringList args = parser.positionalArguments();
|
||||||
QString command = args.isEmpty() ? QString() : args.first();
|
parser.clearPositionalArguments();
|
||||||
|
QueuedctlCommon::preprocess(args, parser);
|
||||||
if (command == "auth") {
|
// parse
|
||||||
QueuedctlAuth::parser(parser);
|
|
||||||
} else if (command == "option-edit") {
|
|
||||||
QueuedctlOption::parser(parser);
|
|
||||||
} else if (command == "task-add") {
|
|
||||||
parser.clearPositionalArguments();
|
|
||||||
} else if (command == "task-edit") {
|
|
||||||
parser.clearPositionalArguments();
|
|
||||||
} else if (command == "user-add") {
|
|
||||||
parser.clearPositionalArguments();
|
|
||||||
} else if (command == "user-edit") {
|
|
||||||
parser.clearPositionalArguments();
|
|
||||||
} else {
|
|
||||||
parser.process(app);
|
|
||||||
qWarning() << "Unknown command" << command;
|
|
||||||
parser.showHelp(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
parser.process(app);
|
parser.process(app);
|
||||||
|
|
||||||
// show info and exit
|
// show info and exit
|
||||||
@ -103,5 +85,10 @@ int main(int argc, char *argv[])
|
|||||||
if (parser.isSet(debugOption))
|
if (parser.isSet(debugOption))
|
||||||
QueuedDebug::enableDebug();
|
QueuedDebug::enableDebug();
|
||||||
|
|
||||||
return 0;
|
// process
|
||||||
|
auto result = QueuedctlCommon::process(parser, parser.value(tokenOption),
|
||||||
|
parser.value(userOption));
|
||||||
|
QueuedctlCommon::print(result);
|
||||||
|
|
||||||
|
return result.status ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user