Add ability to specify working directory to the dispatcher, and update the new fetch_ports API call.

This commit is contained in:
Ken Moore
2017-10-04 10:56:43 -04:00
parent 068ef24a66
commit 52ae9e8e5c
3 changed files with 16 additions and 15 deletions

View File

@@ -196,31 +196,32 @@ void Dispatcher::stop(){
}
//Overloaded Main Calling Functions (single command, or multiple in-order commands)
DProcess* Dispatcher::queueProcess(QString ID, QString cmd){
return queueProcess(NO_QUEUE, ID, QStringList() << cmd);
DProcess* Dispatcher::queueProcess(QString ID, QString cmd, QString workdir){
return queueProcess(NO_QUEUE, ID, QStringList() << cmd, workdir);
}
DProcess* Dispatcher::queueProcess(QString ID, QStringList cmds){
return queueProcess(NO_QUEUE, ID, cmds);
DProcess* Dispatcher::queueProcess(QString ID, QStringList cmds, QString workdir){
return queueProcess(NO_QUEUE, ID, cmds, workdir);
}
DProcess* Dispatcher::queueProcess(Dispatcher::PROC_QUEUE queue, QString ID, QString cmd){
return queueProcess(queue, ID, QStringList() << cmd);
DProcess* Dispatcher::queueProcess(Dispatcher::PROC_QUEUE queue, QString ID, QString cmd, QString workdir){
return queueProcess(queue, ID, QStringList() << cmd, workdir);
}
DProcess* Dispatcher::queueProcess(Dispatcher::PROC_QUEUE queue, QString ID, QStringList cmds){
DProcess* Dispatcher::queueProcess(Dispatcher::PROC_QUEUE queue, QString ID, QStringList cmds, QString workdir){
//This is the primary queueProcess() function - all the overloads end up here to do the actual work
//For multi-threading, need to emit a signal/slot for this action (object creations need to be in same thread as parent)
//qDebug() << "Queue Process:" << queue << ID << cmds;
DProcess *P = createProcess(ID, cmds);
DProcess *P = createProcess(ID, cmds, workdir);
this->emit mkprocs(queue, P);
return P;
}
// === PRIVATE ===
//Simplification routine for setting up a process
DProcess* Dispatcher::createProcess(QString ID, QStringList cmds){
DProcess* Dispatcher::createProcess(QString ID, QStringList cmds, QString workdir){
DProcess *P = new DProcess();
P->moveToThread(this->thread());
P->cmds = cmds;
P->ID = ID;
if(!workdir.isEmpty()){ P->setWorkingDirectory(workdir); }
return P;
}

View File

@@ -70,10 +70,10 @@ public slots:
void stop(); //save any currently-unrun processes for next time
//Main Calling Functions (single command, or multiple in-order commands)
DProcess* queueProcess(QString ID, QString cmd); //uses NO_QUEUE
DProcess* queueProcess(QString ID, QStringList cmds); //uses NO_QUEUE
DProcess* queueProcess(Dispatcher::PROC_QUEUE, QString ID, QString cmd);
DProcess* queueProcess(Dispatcher::PROC_QUEUE, QString ID, QStringList cmds);
DProcess* queueProcess(QString ID, QString cmd, QString workdir = ""); //uses NO_QUEUE
DProcess* queueProcess(QString ID, QStringList cmds, QString workdir = ""); //uses NO_QUEUE
DProcess* queueProcess(Dispatcher::PROC_QUEUE, QString ID, QString cmd, QString workdir = "");
DProcess* queueProcess(Dispatcher::PROC_QUEUE, QString ID, QStringList cmds, QString workdir = "");
private:
// Queue file
@@ -83,7 +83,7 @@ private:
QHash<PROC_QUEUE, QList<DProcess*> > HASH;
//Simplification routine for setting up a process
DProcess* createProcess(QString ID, QStringList cmds);
DProcess* createProcess(QString ID, QStringList cmds, QString workdir = "");
QJsonObject CreateDispatcherEventNotification(QString, QJsonObject);
// Functions to do parsing out dispatcher queued tasks

View File

@@ -449,7 +449,7 @@ QJsonObject SysMgmt::fetchPortsTree(QString altDir){
}
//Now update the tree with git
QString ID = "system_fetch_ports_tree";
DISPATCHER->queueProcess(ID, QStringList() << "cd \""+altDir+"\"" << "git fetch" << "git pull" );
DISPATCHER->queueProcess(ID, "git pull origin", altDir );
out.insert("result","process_started");
out.insert("process_id",ID);
return out;