summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2013-06-17 12:11:51 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-06-17 16:09:10 +0100
commit3ea9d647ec35c4d30dcaa5b58e9471b775a4716c (patch)
treee3e5022ce0e34320bd555942c418a3cb02282651 /bitbake/lib/bb/ui
parent194b395f85dbed216b7dd51e66f8b567955307f2 (diff)
downloadpoky-3ea9d647ec35c4d30dcaa5b58e9471b775a4716c.tar.gz
bitbake: knotty, xmlrpc: add observer-only mode
I add an observer only mode for the knotty UI and the XMLRPC server that will allow the UI to register a callback with a server in order to receive events. The observer-UI is able to send read-only commands to the server, and also is able to register as an event handler. Read-only commands are the commands that do not change the state of the server and have been marked as such in the command module. The observer can switch to a full client if it calls addClient at any time, and the server has no other client running. (Bitbake rev: 4de9ee21f1fa4d04937cc7430fb1fc8b7a8f61e2) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui')
-rw-r--r--bitbake/lib/bb/ui/knotty.py29
-rw-r--r--bitbake/lib/bb/ui/uievent.py1
2 files changed, 18 insertions, 12 deletions
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 389c3cc64d..c6a1d3f98a 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -216,21 +216,25 @@ class TerminalFilter(object):
216 fd = sys.stdin.fileno() 216 fd = sys.stdin.fileno()
217 self.termios.tcsetattr(fd, self.termios.TCSADRAIN, self.stdinbackup) 217 self.termios.tcsetattr(fd, self.termios.TCSADRAIN, self.stdinbackup)
218 218
219def main(server, eventHandler, params, tf = TerminalFilter): 219def _log_settings_from_server(server):
220
221 # Get values of variables which control our output 220 # Get values of variables which control our output
222 includelogs, error = server.runCommand(["getVariable", "BBINCLUDELOGS"]) 221 includelogs, error = server.runCommand(["getVariable", "BBINCLUDELOGS"])
223 if error: 222 if error:
224 logger.error("Unable to get the value of BBINCLUDELOGS variable: %s" % error) 223 logger.error("Unable to get the value of BBINCLUDELOGS variable: %s" % error)
225 return 1 224 raise BaseException(error)
226 loglines, error = server.runCommand(["getVariable", "BBINCLUDELOGS_LINES"]) 225 loglines, error = server.runCommand(["getVariable", "BBINCLUDELOGS_LINES"])
227 if error: 226 if error:
228 logger.error("Unable to get the value of BBINCLUDELOGS_LINES variable: %s" % error) 227 logger.error("Unable to get the value of BBINCLUDELOGS_LINES variable: %s" % error)
229 return 1 228 raise BaseException(error)
230 consolelogfile, error = server.runCommand(["getVariable", "BB_CONSOLELOG"]) 229 consolelogfile, error = server.runCommand(["getVariable", "BB_CONSOLELOG"])
231 if error: 230 if error:
232 logger.error("Unable to get the value of BB_CONSOLELOG variable: %s" % error) 231 logger.error("Unable to get the value of BB_CONSOLELOG variable: %s" % error)
233 return 1 232 raise BaseException(error)
233 return includelogs, loglines, consolelogfile
234
235def main(server, eventHandler, params, tf = TerminalFilter):
236
237 includelogs, loglines, consolelogfile = _log_settings_from_server(server)
234 238
235 if sys.stdin.isatty() and sys.stdout.isatty(): 239 if sys.stdin.isatty() and sys.stdout.isatty():
236 log_exec_tty = True 240 log_exec_tty = True
@@ -254,7 +258,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
254 consolelog.setFormatter(conlogformat) 258 consolelog.setFormatter(conlogformat)
255 logger.addHandler(consolelog) 259 logger.addHandler(consolelog)
256 260
257 try: 261 if not params.observe_only:
258 params.updateFromServer(server) 262 params.updateFromServer(server)
259 cmdline = params.parseActions() 263 cmdline = params.parseActions()
260 if not cmdline: 264 if not cmdline:
@@ -271,9 +275,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
271 elif ret != True: 275 elif ret != True:
272 logger.error("Command '%s' failed: returned %s" % (cmdline, ret)) 276 logger.error("Command '%s' failed: returned %s" % (cmdline, ret))
273 return 1 277 return 1
274 except xmlrpclib.Fault as x: 278
275 logger.error("XMLRPC Fault getting commandline:\n %s" % x)
276 return 1
277 279
278 parseprogress = None 280 parseprogress = None
279 cacheprogress = None 281 cacheprogress = None
@@ -320,7 +322,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
320 elif event.levelno == format.WARNING: 322 elif event.levelno == format.WARNING:
321 warnings = warnings + 1 323 warnings = warnings + 1
322 # For "normal" logging conditions, don't show note logs from tasks 324 # For "normal" logging conditions, don't show note logs from tasks
323 # but do show them if the user has changed the default log level to 325 # but do show them if the user has changed the default log level to
324 # include verbose/debug messages 326 # include verbose/debug messages
325 if event.taskpid != 0 and event.levelno <= format.NOTE: 327 if event.taskpid != 0 and event.levelno <= format.NOTE:
326 continue 328 continue
@@ -469,12 +471,15 @@ def main(server, eventHandler, params, tf = TerminalFilter):
469 pass 471 pass
470 except KeyboardInterrupt: 472 except KeyboardInterrupt:
471 termfilter.clearFooter() 473 termfilter.clearFooter()
472 if main.shutdown == 1: 474 if params.observe_only:
475 print("\nKeyboard Interrupt, exiting observer...")
476 main.shutdown = 2
477 if not params.observe_only and main.shutdown == 1:
473 print("\nSecond Keyboard Interrupt, stopping...\n") 478 print("\nSecond Keyboard Interrupt, stopping...\n")
474 _, error = server.runCommand(["stateStop"]) 479 _, error = server.runCommand(["stateStop"])
475 if error: 480 if error:
476 logger.error("Unable to cleanly stop: %s" % error) 481 logger.error("Unable to cleanly stop: %s" % error)
477 if main.shutdown == 0: 482 if not params.observe_only and main.shutdown == 0:
478 print("\nKeyboard Interrupt, closing down...\n") 483 print("\nKeyboard Interrupt, closing down...\n")
479 interrupted = True 484 interrupted = True
480 _, error = server.runCommand(["stateShutdown"]) 485 _, error = server.runCommand(["stateShutdown"])
diff --git a/bitbake/lib/bb/ui/uievent.py b/bitbake/lib/bb/ui/uievent.py
index 0b9a836d0f..038029fcfa 100644
--- a/bitbake/lib/bb/ui/uievent.py
+++ b/bitbake/lib/bb/ui/uievent.py
@@ -84,6 +84,7 @@ class BBUIEventQueue:
84 84
85 def startCallbackHandler(self): 85 def startCallbackHandler(self):
86 86
87 self.server.timeout = 1
87 while not self.server.quit: 88 while not self.server.quit:
88 self.server.handle_request() 89 self.server.handle_request()
89 self.server.server_close() 90 self.server.server_close()