QStringList RunCommand(QString const& command, QStringList const& arguments, unsigned int waitTimeInMilliSeconds) { QStringList output; QFileInfo cmd(command); if (cmd.exists()) { qDebug() << "Executing command" << command << "with args:" << arguments; QProcess process; process.setWorkingDirectory(cmd.absolutePath()); process.start(cmd.fileName(), arguments); if (process.waitForFinished(waitTimeInMilliSeconds)) { QString psOutput(process.readAllStandardOutput()); output = psOutput.split(QRegExp("\\n")); }else { // should throw an exception process.kill(); } }else { QString msg("Could not find command "); msg += command; QMessageBox::warning(0, "IQmol", msg); } return output; }
void textHist2(char *inFile) /* textHist2 - Make two dimensional histogram. */ { int bothBins = xBins * yBins; int *hist = needMem(bothBins * sizeof(int)); char *row[2]; struct lineFile *lf = lineFileOpen(inFile, TRUE); int x, y, both; /* Read file and make counts. */ while (lineFileRow(lf, row)) { x = lineFileNeedNum(lf, row, 0); y = lineFileNeedNum(lf, row, 1); if (x >= xMin && y >= yMin) { x = (x - xMin)/xBinSize; y = (y - yMin)/yBinSize; if (x >= 0 && x < xBins && y >= 0 && y < yBins) { both = y*xBins + x; ++hist[both]; } } } /* Output it. */ if (psFile != NULL) psOutput(hist, psFile); else textOutput(hist); }
std::ostream& operator << (std::ostream& out, ProcessSnapShot<char>& procs){ ProcInfo<std::string> pInfo = procs.procInfo; return psOutput(out, pInfo); }