Exemplo n.º 1
0
void SessionListWidget::parseQstat(QString const& qstat)
{
   QStringList lines = qstat.split('\n');

   JobDefinition *job = NULL;
   QMap<QString, QString> jobSpec, jobVars;

   QRegExp rxJobId("[0-9]+\\.pbs01");
   QRegExp rxKey("[A-Za-z_\\.]+");
   QString key(""), value("");
   for(QStringList::const_iterator line = lines.begin();
       line != lines.end();
       line++)
   {
      if(line->isEmpty()) { /* empty */ }
      else if(line->startsWith("Job Id:")) {
         if(job != NULL) {
            job->update(jobSpec);
            sessions.append(*job);
            delete job;
            job = NULL;
            jobSpec.clear();
            jobVars.clear();
         }
         rxJobId.indexIn(*line);
         job = new JobDefinition(rxJobId.cap());
      }
      else if(line->startsWith("    ")) {  /* keys start with 4 spaces */
         if(key == "Variable_List") {
            QStringList vars(jobSpec[key].split(","));
            for(QStringList::const_iterator i = vars.begin();
                i != vars.end(); 
                i++)
            {
               int eq = i->indexOf('=');
               jobVars.insert(i->left(eq), i->mid(eq + 1));
            }
         }
         rxKey.indexIn(*line);
         key = rxKey.cap(0);
         value = line->mid(line->indexOf('=') + 2);
         jobSpec.insert(key, value);
      }
      else if(line->at(0) == '\t') {
         /* append to the previous key */
         jobSpec[key].append(line->mid(1));
      }
   }
   if(job) {
      job->update(jobSpec);
      sessions.append(*job);
   }

   qDebug() << sessions;
}
void MakefileFactory::setEnvironment(const QStringList &env)
{
    for (QStringList::const_iterator it = env.begin(); it != env.end(); ++it) {
        int idx = it->indexOf(QLatin1Char('='));
        if (idx >= 0)
            m_environment.insert(it->left(idx), it->mid(idx + 1));
    }
}