Skip to content
Snippets Groups Projects
Commit e2212007 authored by Iustin Pop's avatar Iustin Pop
Browse files

Improve cli.SubmitOpCode

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
parent f1048938
No related branches found
No related tags found
No related merge requests found
...@@ -369,7 +369,7 @@ def AskUser(text, choices=None): ...@@ -369,7 +369,7 @@ def AskUser(text, choices=None):
return answer return answer
def SubmitOpCode(op, proc=None, feedback_fn=None): def SubmitOpCode(op, cl=None, feedback_fn=None):
"""Legacy function to submit an opcode. """Legacy function to submit an opcode.
This is just a simple wrapper over the construction of the processor This is just a simple wrapper over the construction of the processor
...@@ -377,8 +377,8 @@ def SubmitOpCode(op, proc=None, feedback_fn=None): ...@@ -377,8 +377,8 @@ def SubmitOpCode(op, proc=None, feedback_fn=None):
interaction functions. interaction functions.
""" """
# TODO: Fix feedback_fn situation. if cl is None:
cl = luxi.Client() cl = luxi.Client()
job_id = cl.SubmitJob([op]) job_id = cl.SubmitJob([op])
...@@ -395,7 +395,10 @@ def SubmitOpCode(op, proc=None, feedback_fn=None): ...@@ -395,7 +395,10 @@ def SubmitOpCode(op, proc=None, feedback_fn=None):
break break
msg = jobs[0][1] msg = jobs[0][1]
if msg is not None and msg != lastmsg: 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 lastmsg = msg
time.sleep(1) time.sleep(1)
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
import os import os
import sys import sys
import optparse import optparse
import time
from itertools import izip, islice, cycle from itertools import izip, islice, cycle
from cStringIO import StringIO from cStringIO import StringIO
...@@ -81,15 +82,14 @@ class Burner(object): ...@@ -81,15 +82,14 @@ class Burner(object):
def Feedback(self, msg): def Feedback(self, msg):
"""Acumulate feedback in our buffer.""" """Acumulate feedback in our buffer."""
self._feed_buf.write(msg) self._feed_buf.write("%s %s\n" % (time.ctime(msg[0]), msg[2]))
self._feed_buf.write("\n")
if self.opts.verbose: if self.opts.verbose:
Log(msg) Log(msg)
def ExecOp(self, op): def ExecOp(self, op):
"""Execute an opcode and manage the exec buffer.""" """Execute an opcode and manage the exec buffer."""
self.ClearFeedbackBuf() self.ClearFeedbackBuf()
return cli.SubmitOpCode(op) return cli.SubmitOpCode(op, feedback_fn=self.Feedback)
def ParseOptions(self): def ParseOptions(self):
"""Parses the command line options. """Parses the command line options.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment