From 4474f11290d5f3ca0e013013a8cf6a9f1ce54293 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 27 Jul 2011 18:46:47 +0200 Subject: [PATCH] Revert "cli.JobExecutor: Feedback function for info output" This reverts commit 7421df8e5f2cf31022085b332d1300640ba5854b. The feedback_fn argument to JobExecutor is used for PollJob, and thus has a fixed signature: a single arg, tuple of (timestamp, log type, log message). It's use as drop-in replacement for ToStdout doesn't work, as that function has a different signature. For now, I propose to revert this, until we either change JobExecutor to use the same log messages (and add an intermediate wrapper between JobExecutor and ToStdout) or we add another parameter to JobExecutor.__init__. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/cli.py | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/lib/cli.py b/lib/cli.py index 06c460fff..dcc13ad15 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -3016,10 +3016,6 @@ class JobExecutor(object): self.jobs = [] self.opts = opts self.feedback_fn = feedback_fn - if feedback_fn: - self._info_fn = feedback_fn - else: - self._info_fn = ToStdout self._counter = itertools.count() @staticmethod @@ -3101,33 +3097,31 @@ class JobExecutor(object): if self.verbose: ok_jobs = [row[2] for row in self.jobs if row[1]] if ok_jobs: - self._info_fn("Submitted jobs %s", utils.CommaJoin(ok_jobs)) + ToStdout("Submitted jobs %s", utils.CommaJoin(ok_jobs)) # first, remove any non-submitted jobs self.jobs, failures = compat.partition(self.jobs, lambda x: x[1]) for idx, _, jid, name in failures: - self._info_fn("Failed to submit job%s: %s", - self._IfName(name, " for %s"), jid) + ToStderr("Failed to submit job%s: %s", self._IfName(name, " for %s"), jid) results.append((idx, False, jid)) while self.jobs: (idx, _, jid, name) = self._ChooseJob() - self._info_fn("Waiting for job %s%s ...", - jid, self._IfName(name, " for %s")) + ToStdout("Waiting for job %s%s ...", jid, self._IfName(name, " for %s")) try: job_result = PollJob(jid, cl=self.cl, feedback_fn=self.feedback_fn) success = True except errors.JobLost, err: _, job_result = FormatError(err) - self._info_fn("Job %s%s has been archived, cannot check its result", - jid, self._IfName(name, " for %s")) + ToStderr("Job %s%s has been archived, cannot check its result", + jid, self._IfName(name, " for %s")) success = False except (errors.GenericError, luxi.ProtocolError), err: _, job_result = FormatError(err) success = False # the error message will always be shown, verbose or not - self._info_fn("Job %s%s has failed: %s", - jid, self._IfName(name, " for %s"), job_result) + ToStderr("Job %s%s has failed: %s", + jid, self._IfName(name, " for %s"), job_result) results.append((idx, success, job_result)) @@ -3151,9 +3145,9 @@ class JobExecutor(object): self.SubmitPending() for _, status, result, name in self.jobs: if status: - self._info_fn("%s: %s", result, name) + ToStdout("%s: %s", result, name) else: - self._info_fn("Failure for %s: %s", name, result) + ToStderr("Failure for %s: %s", name, result) return [row[1:3] for row in self.jobs] -- GitLab