summaryrefslogtreecommitdiff
path: root/util/ec3po/console.py
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2016-02-01 18:21:28 -0800
committerchrome-bot <chrome-bot@chromium.org>2016-02-03 17:16:33 -0800
commit086e501be397b3e14693b2dfd6a235dcc86844a0 (patch)
tree70b2d01a6287f977cb146fd3350a40ba9c47f1c9 /util/ec3po/console.py
parentf6f06c95d673c8912e2ddabe00a0606c20823b04 (diff)
downloadchrome-ec-086e501be397b3e14693b2dfd6a235dcc86844a0.tar.gz
util: ec3po: Add OOBM queue and dynamic loglevels.
This commit adds an Out Of Band Managament queue which will allow the console to receive commands outside of the PTY which it can take action on. The first use of this is to dynamically change the logging level. Prior to this change, changing the log level using dut-control would not affect the log level of the console or interpreter. BUG=None BRANCH=None TEST=Launch modified servod; issue dut-control loglevel:debug, verify that debug messages from both servod and ec3po are emitted. Then issue dut-control loglevel:info and verify that no debug messages from either are emitted. Change-Id: I692824742b018da9540a81305985f6f355f716e6 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/325134 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'util/ec3po/console.py')
-rwxr-xr-xutil/ec3po/console.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/util/ec3po/console.py b/util/ec3po/console.py
index 2a426ac700..e75523e80b 100755
--- a/util/ec3po/console.py
+++ b/util/ec3po/console.py
@@ -86,6 +86,8 @@ class Console(object):
dbg_pipe: A multiprocessing.Connection object which represents the console's
read-only side of the debug pipe. This must be a unidirectional pipe
attached to the intepreter. EC debug messages use this pipe.
+ oobm_queue: A multiprocessing.Queue which is used for out of band management
+ for the interactive console.
input_buffer: A string representing the current input command.
input_buffer_pos: An integer representing the current position in the buffer
to insert a char.
@@ -127,6 +129,7 @@ class Console(object):
self.user_pty = user_pty
self.cmd_pipe = cmd_pipe
self.dbg_pipe = dbg_pipe
+ self.oobm_queue = multiprocessing.Queue()
self.input_buffer = ''
self.input_buffer_pos = 0
self.partial_cmd = ''
@@ -145,6 +148,7 @@ class Console(object):
string.append('user_pty: %s' % self.user_pty)
string.append('cmd_pipe: %s' % self.cmd_pipe)
string.append('dbg_pipe: %s' % self.dbg_pipe)
+ string.append('oobm_queue: %s' % self.oobm_queue)
string.append('input_buffer: %s' % self.input_buffer)
string.append('input_buffer_pos: %d' % self.input_buffer_pos)
string.append('esc_state: %d' % self.esc_state)
@@ -695,6 +699,19 @@ def StartLoop(console):
console.logger.debug('|DBG|->\'%s\'', data)
os.write(console.master_pty, data)
+ while not console.oobm_queue.empty():
+ console.logger.debug('OOBM queue ready for reading.')
+ cmd = console.oobm_queue.get()
+ console.logger.debug('cmd: %s', cmd)
+ if cmd.startswith('loglevel'):
+ console.logger.debug('Log level change request.')
+ new_log_level = int(cmd.split(' ')[1])
+ console.logger.logger.setLevel(new_log_level)
+ console.logger.info('Log level changed to %d.', new_log_level)
+
+ # Forward the request to the interpreter as well.
+ console.cmd_pipe.send(cmd)
+
finally:
# Close pipes.
console.dbg_pipe.close()