From e2212007105454572424bcff0ccfcc890f568c18 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Mon, 14 Jul 2008 13:38:14 +0000 Subject: [PATCH] Improve cli.SubmitOpCode MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Currently, the feedback_fn argument to SubmitOpCode is no longer used. We still need it in burnin, so we re-enable it by making the code call that function with the msg argument in case feedback_fn is callable. The patch also modifies burnin to accept the new argument format (msg is not a triple instead of a string). The patch also removes the ‘proc’ argument as it's obsolete; instead we can accept a luxi.Client instance (noone uses this right now). Reviewed-by: ultrotter --- lib/cli.py | 11 +++++++---- tools/burnin | 6 +++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/cli.py b/lib/cli.py index 34a2bfb..1eab656 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -369,7 +369,7 @@ def AskUser(text, choices=None): return answer -def SubmitOpCode(op, proc=None, feedback_fn=None): +def SubmitOpCode(op, cl=None, feedback_fn=None): """Legacy function to submit an opcode. This is just a simple wrapper over the construction of the processor @@ -377,8 +377,8 @@ def SubmitOpCode(op, proc=None, feedback_fn=None): interaction functions. """ - # TODO: Fix feedback_fn situation. - cl = luxi.Client() + if cl is None: + cl = luxi.Client() job_id = cl.SubmitJob([op]) @@ -395,7 +395,10 @@ def SubmitOpCode(op, proc=None, feedback_fn=None): break msg = jobs[0][1] if msg is not None and msg != lastmsg: - print "%s %s" % (time.ctime(msg[0]), msg[2]) + if callable(feedback_fn): + feedback_fn(msg) + else: + print "%s %s" % (time.ctime(msg[0]), msg[2]) lastmsg = msg time.sleep(1) diff --git a/tools/burnin b/tools/burnin index 339a7e2..cfa848a 100755 --- a/tools/burnin +++ b/tools/burnin @@ -26,6 +26,7 @@ import os import sys import optparse +import time from itertools import izip, islice, cycle from cStringIO import StringIO @@ -81,15 +82,14 @@ class Burner(object): def Feedback(self, msg): """Acumulate feedback in our buffer.""" - self._feed_buf.write(msg) - self._feed_buf.write("\n") + self._feed_buf.write("%s %s\n" % (time.ctime(msg[0]), msg[2])) if self.opts.verbose: Log(msg) def ExecOp(self, op): """Execute an opcode and manage the exec buffer.""" self.ClearFeedbackBuf() - return cli.SubmitOpCode(op) + return cli.SubmitOpCode(op, feedback_fn=self.Feedback) def ParseOptions(self): """Parses the command line options. -- 1.7.10.4