3 #include "branchitem.h"
4 #include "mainwindow.h"
7 extern Main *mainWindow;
9 BugAgent::BugAgent (BranchItem *bi,const QString &bug)
13 qWarning ("Const BugAgent: bi==NULL");
17 modelID=bi->getModel()->getID();
20 script="test/vym-bug.pl";
24 connect (p, SIGNAL (finished(int,QProcess::ExitStatus) ),
25 this, SLOT (processFinished(int,QProcess::ExitStatus) ));
27 p->start (script,QStringList()<<bugID);
28 if (!p->waitForStarted())
30 qWarning()<<"BugAgent::getBugzillaData couldn't start "<<script;
35 QString result=getStdout();
36 while (result.endsWith("\n")) result.chop(1);
37 //qWarning << QString(result);
38 QString err=getErrout();
41 qWarning << "BugAgent::getBugzillaData Error:\n";
44 else if (!result.isEmpty())
52 BugAgent::~BugAgent ()
55 qDebug ()<<"dest BugAgent";
58 void BugAgent::processFinished(int exitCode, QProcess::ExitStatus exitStatus)
60 if (exitStatus==QProcess::NormalExit)
62 VymModel *model=mainWindow->getModel (modelID);
65 BranchItem *bi=(BranchItem*)(model->findID (branchID));
68 QString oldsel=model->getSelectString ();
71 // Now do needed changes:
73 QString result=p->getStdout();
74 while (result.endsWith("\n")) result.chop(1);
75 //qWarning() << QString(result);
76 QString err=p->getErrout();
79 qWarning() << "VM::BugAgent Error:\n";
82 else if (!result.isEmpty())
84 QString heading,cdate,mdate,state,whiteboard;
85 QRegExp re("short_desc:(.*)\n");
87 if (re.indexIn (result) !=-1) heading=re.cap(1);
89 re.setPattern ("creation_ts:(.*)\n");
90 if (re.indexIn (result) !=-1) cdate=re.cap(1);
92 re.setPattern ("delta_ts:(.*)\n");
93 if (re.indexIn (result) !=-1) mdate=re.cap(1);
95 re.setPattern ("bug_status:(.*)\n");
96 if (re.indexIn (result) !=-1) state=re.cap(1);
98 re.setPattern ("status_whiteboard:(.*)\n");
99 if (re.indexIn (result) !=-1) whiteboard=re.cap(1);
101 model->setHeading (bugID + " - " + heading);
102 qDebug() << "VM: heading="<<heading;
103 qDebug() << "VM: cdate="<<cdate;
104 qDebug() << "VM: mdate="<<mdate;
105 qDebug() << "VM: state="<<state;
106 qDebug() << "VM: wboard="<<whiteboard;
108 //qDebug() <<"VM::getBugzillaData "<<script<<" returned:\n";
109 //qDebug() <<QString(result);
111 qWarning() << "VM::getBugzillaData "<<script<<" returned nothing\n";
116 model->select (oldsel);
118 qWarning ()<<"BugAgent: Found model, but not branch #"<<branchID;
120 qWarning ()<<"BugAgent: Couldn't find model #"<<modelID;
122 qWarning()<< "BugAgent: Process finished with exitCode="<<exitCode;