Esempio n. 1
0
void RestartCmd::RestartTask::reportStatus(const ProcessRunner& r)
{
  if(r.error())
    context().errorLine("Robot \"" + robot->name + "\" is unreachable");
  else
    context().printLine("Robot \"" + robot->name + "\" restarted");
}
int TarExtractTaskHelper::calculateNumberOfFilesToExtract() {
    ProcessRunner processRunner;
    Process* process = processRunner.getProcess();
    (*process) << "/bin/sh" << "-c" <<
                  "tar -t " + mTarFormat + " -f " + mFileToUnpack.getPath() +
                  " | wc -l" ;

    notifyTaskLogger("Calculating number of files to extract (" +
                            process->getArgumentsAsString() + ")\n", message);

    process->start();

    if (!processRunner.getStderrData().empty()) {
        notifyTaskLogger("Error while calculating number of files to extract:" +
                                processRunner.getStderrData(), error);
        return 0;
    }

    istringstream toInt(processRunner.getStdoutData());
    int numberOfFilesToExtract;
    toInt >> numberOfFilesToExtract;

    notifyTaskLogger("Done: " + processRunner.getStdoutData(), message);

    return numberOfFilesToExtract;
}
Esempio n. 3
0
bool PingCmd::PingTask::isReachable(ProcessRunner& r)
{
  return r.getProcess()->exitCode() == 0;
}
Esempio n. 4
0
bool PingCmd::PingTask::isReachable(ProcessRunner& r)
{
  // some times ping tells me that the host wasn't found but returns an good exit code
  return r.getProcess()->exitCode() == 0 && r.getOutput().contains("TTL=");
}