2008-09-30 15:08:33 +00:00
|
|
|
#
|
|
|
|
# BitBake Graphical GTK based Dependency Explorer
|
|
|
|
#
|
|
|
|
# Copyright (C) 2007 Ross Burton
|
|
|
|
# Copyright (C) 2007 - 2008 Richard Purdie
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License version 2 as
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
2015-02-16 08:25:02 +00:00
|
|
|
import sys
|
2016-06-20 12:20:03 +00:00
|
|
|
import gi
|
|
|
|
gi.require_version('Gtk', '3.0')
|
|
|
|
from gi.repository import Gtk, Gdk, GObject
|
|
|
|
from multiprocessing import Queue
|
2008-09-30 15:08:33 +00:00
|
|
|
import threading
|
2016-06-20 12:20:03 +00:00
|
|
|
from xmlrpc import client
|
|
|
|
import time
|
2010-12-10 23:53:19 +00:00
|
|
|
import bb
|
|
|
|
import bb.event
|
2008-09-30 15:08:33 +00:00
|
|
|
|
|
|
|
# Package Model
|
|
|
|
(COL_PKG_NAME) = (0)
|
|
|
|
|
|
|
|
# Dependency Model
|
|
|
|
(TYPE_DEP, TYPE_RDEP) = (0, 1)
|
|
|
|
(COL_DEP_TYPE, COL_DEP_PARENT, COL_DEP_PACKAGE) = (0, 1, 2)
|
|
|
|
|
2010-12-17 15:20:39 +00:00
|
|
|
|
2016-06-20 12:20:03 +00:00
|
|
|
class PackageDepView(Gtk.TreeView):
|
2008-09-30 15:08:33 +00:00
|
|
|
def __init__(self, model, dep_type, label):
|
2016-06-20 12:20:03 +00:00
|
|
|
Gtk.TreeView.__init__(self)
|
2008-09-30 15:08:33 +00:00
|
|
|
self.current = None
|
|
|
|
self.dep_type = dep_type
|
|
|
|
self.filter_model = model.filter_new()
|
2016-06-20 12:20:03 +00:00
|
|
|
self.filter_model.set_visible_func(self._filter, data=None)
|
2008-09-30 15:08:33 +00:00
|
|
|
self.set_model(self.filter_model)
|
2016-06-20 12:20:03 +00:00
|
|
|
self.append_column(Gtk.TreeViewColumn(label, Gtk.CellRendererText(), text=COL_DEP_PACKAGE))
|
2008-09-30 15:08:33 +00:00
|
|
|
|
2016-06-20 12:20:03 +00:00
|
|
|
def _filter(self, model, iter, data):
|
|
|
|
this_type = model[iter][COL_DEP_TYPE]
|
|
|
|
package = model[iter][COL_DEP_PARENT]
|
2008-09-30 15:08:33 +00:00
|
|
|
if this_type != self.dep_type: return False
|
|
|
|
return package == self.current
|
|
|
|
|
|
|
|
def set_current_package(self, package):
|
|
|
|
self.current = package
|
|
|
|
self.filter_model.refilter()
|
|
|
|
|
2010-12-17 15:20:39 +00:00
|
|
|
|
2016-06-20 12:20:03 +00:00
|
|
|
class PackageReverseDepView(Gtk.TreeView):
|
2008-09-30 15:08:33 +00:00
|
|
|
def __init__(self, model, label):
|
2016-06-20 12:20:03 +00:00
|
|
|
Gtk.TreeView.__init__(self)
|
2008-09-30 15:08:33 +00:00
|
|
|
self.current = None
|
|
|
|
self.filter_model = model.filter_new()
|
|
|
|
self.filter_model.set_visible_func(self._filter)
|
|
|
|
self.set_model(self.filter_model)
|
2016-06-20 12:20:03 +00:00
|
|
|
self.append_column(Gtk.TreeViewColumn(label, Gtk.CellRendererText(), text=COL_DEP_PARENT))
|
2008-09-30 15:08:33 +00:00
|
|
|
|
2016-06-20 12:20:03 +00:00
|
|
|
def _filter(self, model, iter, data):
|
|
|
|
package = model[iter][COL_DEP_PACKAGE]
|
2008-09-30 15:08:33 +00:00
|
|
|
return package == self.current
|
|
|
|
|
|
|
|
def set_current_package(self, package):
|
|
|
|
self.current = package
|
|
|
|
self.filter_model.refilter()
|
|
|
|
|
2010-12-17 15:20:39 +00:00
|
|
|
|
2016-06-20 12:20:03 +00:00
|
|
|
class DepExplorer(Gtk.Window):
|
2008-09-30 15:08:33 +00:00
|
|
|
def __init__(self):
|
2016-06-20 12:20:03 +00:00
|
|
|
Gtk.Window.__init__(self)
|
2017-02-12 15:37:59 +00:00
|
|
|
self.set_title("Task Dependency Explorer")
|
2008-09-30 15:08:33 +00:00
|
|
|
self.set_default_size(500, 500)
|
2016-06-20 12:20:03 +00:00
|
|
|
self.connect("delete-event", Gtk.main_quit)
|
2008-09-30 15:08:33 +00:00
|
|
|
|
|
|
|
# Create the data models
|
2016-06-20 12:20:03 +00:00
|
|
|
self.pkg_model = Gtk.ListStore(GObject.TYPE_STRING)
|
|
|
|
self.pkg_model.set_sort_column_id(COL_PKG_NAME, Gtk.SortType.ASCENDING)
|
|
|
|
self.depends_model = Gtk.ListStore(GObject.TYPE_INT, GObject.TYPE_STRING, GObject.TYPE_STRING)
|
|
|
|
self.depends_model.set_sort_column_id(COL_DEP_PACKAGE, Gtk.SortType.ASCENDING)
|
2008-09-30 15:08:33 +00:00
|
|
|
|
2016-06-20 12:20:03 +00:00
|
|
|
pane = Gtk.HPaned()
|
2008-09-30 15:08:33 +00:00
|
|
|
pane.set_position(250)
|
|
|
|
self.add(pane)
|
|
|
|
|
|
|
|
# The master list of packages
|
2016-06-20 12:20:03 +00:00
|
|
|
scrolled = Gtk.ScrolledWindow()
|
|
|
|
scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
|
|
|
scrolled.set_shadow_type(Gtk.ShadowType.IN)
|
2010-12-17 15:20:39 +00:00
|
|
|
|
2016-06-20 12:20:03 +00:00
|
|
|
self.pkg_treeview = Gtk.TreeView(self.pkg_model)
|
2008-09-30 15:08:33 +00:00
|
|
|
self.pkg_treeview.get_selection().connect("changed", self.on_cursor_changed)
|
2016-06-20 12:20:03 +00:00
|
|
|
column = Gtk.TreeViewColumn("Package", Gtk.CellRendererText(), text=COL_PKG_NAME)
|
2010-12-17 15:20:39 +00:00
|
|
|
self.pkg_treeview.append_column(column)
|
2008-09-30 15:08:33 +00:00
|
|
|
pane.add1(scrolled)
|
|
|
|
scrolled.add(self.pkg_treeview)
|
|
|
|
|
2016-06-20 12:20:03 +00:00
|
|
|
box = Gtk.VBox(homogeneous=True, spacing=4)
|
2008-09-30 15:08:33 +00:00
|
|
|
|
2017-02-12 15:37:59 +00:00
|
|
|
# Task Depends
|
2016-06-20 12:20:03 +00:00
|
|
|
scrolled = Gtk.ScrolledWindow()
|
|
|
|
scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
|
|
|
scrolled.set_shadow_type(Gtk.ShadowType.IN)
|
2017-02-12 15:37:59 +00:00
|
|
|
self.dep_treeview = PackageDepView(self.depends_model, TYPE_DEP, "Dependencies")
|
2008-09-30 15:08:33 +00:00
|
|
|
self.dep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE)
|
|
|
|
scrolled.add(self.dep_treeview)
|
|
|
|
box.add(scrolled)
|
|
|
|
pane.add2(box)
|
|
|
|
|
2017-02-12 15:37:59 +00:00
|
|
|
# Reverse Task Depends
|
2016-06-20 12:20:03 +00:00
|
|
|
scrolled = Gtk.ScrolledWindow()
|
|
|
|
scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
|
|
|
scrolled.set_shadow_type(Gtk.ShadowType.IN)
|
2017-02-12 15:37:59 +00:00
|
|
|
self.revdep_treeview = PackageReverseDepView(self.depends_model, "Dependent Tasks")
|
2008-09-30 15:08:33 +00:00
|
|
|
self.revdep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PARENT)
|
|
|
|
scrolled.add(self.revdep_treeview)
|
|
|
|
box.add(scrolled)
|
|
|
|
pane.add2(box)
|
|
|
|
|
|
|
|
self.show_all()
|
|
|
|
|
|
|
|
def on_package_activated(self, treeview, path, column, data_col):
|
|
|
|
model = treeview.get_model()
|
|
|
|
package = model.get_value(model.get_iter(path), data_col)
|
|
|
|
|
|
|
|
pkg_path = []
|
|
|
|
def finder(model, path, iter, needle):
|
|
|
|
package = model.get_value(iter, COL_PKG_NAME)
|
|
|
|
if package == needle:
|
|
|
|
pkg_path.append(path)
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
self.pkg_model.foreach(finder, package)
|
|
|
|
if pkg_path:
|
|
|
|
self.pkg_treeview.get_selection().select_path(pkg_path[0])
|
|
|
|
self.pkg_treeview.scroll_to_cell(pkg_path[0])
|
|
|
|
|
|
|
|
def on_cursor_changed(self, selection):
|
|
|
|
(model, it) = selection.get_selected()
|
2013-08-05 15:39:47 +00:00
|
|
|
if it is None:
|
2008-09-30 15:08:33 +00:00
|
|
|
current_package = None
|
|
|
|
else:
|
|
|
|
current_package = model.get_value(it, COL_PKG_NAME)
|
|
|
|
self.dep_treeview.set_current_package(current_package)
|
|
|
|
self.revdep_treeview.set_current_package(current_package)
|
|
|
|
|
|
|
|
|
2013-08-05 15:16:32 +00:00
|
|
|
def parse(self, depgraph):
|
2017-02-12 15:37:59 +00:00
|
|
|
for task in depgraph["tdepends"]:
|
|
|
|
self.pkg_model.insert(0, (task,))
|
|
|
|
for depend in depgraph["tdepends"][task]:
|
|
|
|
self.depends_model.insert (0, (TYPE_DEP, task, depend))
|
2008-09-30 15:08:33 +00:00
|
|
|
|
2010-12-17 15:20:39 +00:00
|
|
|
|
2008-09-30 15:08:33 +00:00
|
|
|
class gtkthread(threading.Thread):
|
|
|
|
quit = threading.Event()
|
|
|
|
def __init__(self, shutdown):
|
|
|
|
threading.Thread.__init__(self)
|
|
|
|
self.setDaemon(True)
|
|
|
|
self.shutdown = shutdown
|
2016-06-20 12:20:03 +00:00
|
|
|
if not Gtk.init_check()[0]:
|
|
|
|
sys.stderr.write("Gtk+ init failed. Make sure DISPLAY variable is set.\n")
|
|
|
|
gtkthread.quit.set()
|
2008-09-30 15:08:33 +00:00
|
|
|
|
|
|
|
def run(self):
|
2016-06-20 12:20:03 +00:00
|
|
|
GObject.threads_init()
|
|
|
|
Gdk.threads_init()
|
|
|
|
Gtk.main()
|
2008-09-30 15:08:33 +00:00
|
|
|
gtkthread.quit.set()
|
|
|
|
|
|
|
|
|
2013-05-20 21:54:41 +00:00
|
|
|
def main(server, eventHandler, params):
|
2016-06-20 12:20:03 +00:00
|
|
|
shutdown = 0
|
|
|
|
|
|
|
|
gtkgui = gtkthread(shutdown)
|
|
|
|
gtkgui.start()
|
|
|
|
|
2008-09-30 15:08:33 +00:00
|
|
|
try:
|
2013-05-20 21:54:41 +00:00
|
|
|
params.updateFromServer(server)
|
|
|
|
cmdline = params.parseActions()
|
|
|
|
if not cmdline:
|
bitbake: command: add error to return of runCommand
Currently, command.py can return an error message from runCommand, due to
being unable to run the command, yet few of our UIs (just hob) can handle it
today. This can result in seeing a TypeError with traceback in certain rare
circumstances.
To resolve this, we need a clean way to get errors back from runCommand,
without having to isinstance() the return value. This implements such a thing
by making runCommand also return an error (or None if no error occurred).
As runCommand now has a method of returning errors, we can also alter the
getCmdLineAction bits such that the returned value is just the action, not an
additional message. If a sync command wants to return an error, it raises
CommandError(message), and the message will be passed to the caller
appropriately.
Example Usage:
result, error = server.runCommand(...)
if error:
log.error('Unable to run command: %s' % error)
return 1
(Bitbake rev: 717831b8315cb3904d9b590e633000bc897e8fb6)
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-10-29 20:01:23 +00:00
|
|
|
print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
|
|
|
|
return 1
|
2013-05-20 21:54:41 +00:00
|
|
|
if 'msg' in cmdline and cmdline['msg']:
|
2014-08-21 08:25:24 +00:00
|
|
|
print(cmdline['msg'])
|
2013-05-20 21:54:41 +00:00
|
|
|
return 1
|
|
|
|
cmdline = cmdline['action']
|
|
|
|
if not cmdline or cmdline[0] != "generateDotGraph":
|
2013-11-07 17:04:21 +00:00
|
|
|
print("This UI requires the -g option")
|
bitbake: command: add error to return of runCommand
Currently, command.py can return an error message from runCommand, due to
being unable to run the command, yet few of our UIs (just hob) can handle it
today. This can result in seeing a TypeError with traceback in certain rare
circumstances.
To resolve this, we need a clean way to get errors back from runCommand,
without having to isinstance() the return value. This implements such a thing
by making runCommand also return an error (or None if no error occurred).
As runCommand now has a method of returning errors, we can also alter the
getCmdLineAction bits such that the returned value is just the action, not an
additional message. If a sync command wants to return an error, it raises
CommandError(message), and the message will be passed to the caller
appropriately.
Example Usage:
result, error = server.runCommand(...)
if error:
log.error('Unable to run command: %s' % error)
return 1
(Bitbake rev: 717831b8315cb3904d9b590e633000bc897e8fb6)
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-10-29 20:01:23 +00:00
|
|
|
return 1
|
|
|
|
ret, error = server.runCommand(["generateDepTreeEvent", cmdline[1], cmdline[2]])
|
|
|
|
if error:
|
|
|
|
print("Error running command '%s': %s" % (cmdline, error))
|
|
|
|
return 1
|
|
|
|
elif ret != True:
|
|
|
|
print("Error running command '%s': returned %s" % (cmdline, ret))
|
|
|
|
return 1
|
2016-06-20 12:20:03 +00:00
|
|
|
except client.Fault as x:
|
2010-04-10 02:46:14 +00:00
|
|
|
print("XMLRPC Fault getting commandline:\n %s" % x)
|
2008-09-30 15:08:33 +00:00
|
|
|
return
|
|
|
|
|
2016-06-20 12:20:03 +00:00
|
|
|
if gtkthread.quit.isSet():
|
2015-02-16 08:25:02 +00:00
|
|
|
return
|
|
|
|
|
2016-06-20 12:20:03 +00:00
|
|
|
Gdk.threads_enter()
|
2008-09-30 15:08:33 +00:00
|
|
|
dep = DepExplorer()
|
2016-06-20 12:20:03 +00:00
|
|
|
bardialog = Gtk.Dialog(parent=dep,
|
|
|
|
flags=Gtk.DialogFlags.MODAL|Gtk.DialogFlags.DESTROY_WITH_PARENT)
|
2012-06-19 09:39:18 +00:00
|
|
|
bardialog.set_default_size(400, 50)
|
2016-06-20 12:20:03 +00:00
|
|
|
box = bardialog.get_content_area()
|
|
|
|
pbar = Gtk.ProgressBar()
|
|
|
|
box.pack_start(pbar, True, True, 0)
|
2012-06-19 09:39:18 +00:00
|
|
|
bardialog.show_all()
|
2016-06-20 12:20:03 +00:00
|
|
|
bardialog.connect("delete-event", Gtk.main_quit)
|
|
|
|
Gdk.threads_leave()
|
2008-09-30 15:08:33 +00:00
|
|
|
|
2010-12-17 15:20:39 +00:00
|
|
|
progress_total = 0
|
2008-09-30 15:08:33 +00:00
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
event = eventHandler.waitEvent(0.25)
|
|
|
|
if gtkthread.quit.isSet():
|
2014-11-13 16:33:18 +00:00
|
|
|
_, error = server.runCommand(["stateForceShutdown"])
|
bitbake: command: add error to return of runCommand
Currently, command.py can return an error message from runCommand, due to
being unable to run the command, yet few of our UIs (just hob) can handle it
today. This can result in seeing a TypeError with traceback in certain rare
circumstances.
To resolve this, we need a clean way to get errors back from runCommand,
without having to isinstance() the return value. This implements such a thing
by making runCommand also return an error (or None if no error occurred).
As runCommand now has a method of returning errors, we can also alter the
getCmdLineAction bits such that the returned value is just the action, not an
additional message. If a sync command wants to return an error, it raises
CommandError(message), and the message will be passed to the caller
appropriately.
Example Usage:
result, error = server.runCommand(...)
if error:
log.error('Unable to run command: %s' % error)
return 1
(Bitbake rev: 717831b8315cb3904d9b590e633000bc897e8fb6)
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-10-29 20:01:23 +00:00
|
|
|
if error:
|
|
|
|
print('Unable to cleanly stop: %s' % error)
|
2008-09-30 15:08:33 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
if event is None:
|
|
|
|
continue
|
2010-12-17 15:20:39 +00:00
|
|
|
|
|
|
|
if isinstance(event, bb.event.CacheLoadStarted):
|
|
|
|
progress_total = event.total
|
2016-06-20 12:20:03 +00:00
|
|
|
Gdk.threads_enter()
|
2012-06-19 09:39:18 +00:00
|
|
|
bardialog.set_title("Loading Cache")
|
2016-06-20 12:20:03 +00:00
|
|
|
pbar.set_fraction(0.0)
|
|
|
|
Gdk.threads_leave()
|
2010-12-17 15:20:39 +00:00
|
|
|
|
|
|
|
if isinstance(event, bb.event.CacheLoadProgress):
|
|
|
|
x = event.current
|
2016-06-20 12:20:03 +00:00
|
|
|
Gdk.threads_enter()
|
|
|
|
pbar.set_fraction(x * 1.0 / progress_total)
|
|
|
|
Gdk.threads_leave()
|
2010-12-17 15:20:39 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
if isinstance(event, bb.event.CacheLoadCompleted):
|
|
|
|
continue
|
|
|
|
|
|
|
|
if isinstance(event, bb.event.ParseStarted):
|
|
|
|
progress_total = event.total
|
2011-05-11 00:07:56 +00:00
|
|
|
if progress_total == 0:
|
|
|
|
continue
|
2016-06-20 12:20:03 +00:00
|
|
|
Gdk.threads_enter()
|
|
|
|
pbar.set_fraction(0.0)
|
2012-06-19 09:39:18 +00:00
|
|
|
bardialog.set_title("Processing recipes")
|
2016-06-20 12:20:03 +00:00
|
|
|
Gdk.threads_leave()
|
2010-12-17 15:20:39 +00:00
|
|
|
|
2010-01-19 14:48:19 +00:00
|
|
|
if isinstance(event, bb.event.ParseProgress):
|
2010-12-17 15:20:39 +00:00
|
|
|
x = event.current
|
2016-06-20 12:20:03 +00:00
|
|
|
Gdk.threads_enter()
|
|
|
|
pbar.set_fraction(x * 1.0 / progress_total)
|
|
|
|
Gdk.threads_leave()
|
2010-12-17 15:20:39 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
if isinstance(event, bb.event.ParseCompleted):
|
2016-06-20 12:20:03 +00:00
|
|
|
Gdk.threads_enter()
|
|
|
|
bardialog.set_title("Generating dependency tree")
|
|
|
|
Gdk.threads_leave()
|
2008-09-30 15:08:33 +00:00
|
|
|
continue
|
|
|
|
|
2010-01-19 14:48:19 +00:00
|
|
|
if isinstance(event, bb.event.DepTreeGenerated):
|
2016-06-20 12:20:03 +00:00
|
|
|
Gdk.threads_enter()
|
|
|
|
bardialog.hide()
|
2013-08-05 15:16:32 +00:00
|
|
|
dep.parse(event._depgraph)
|
2016-06-20 12:20:03 +00:00
|
|
|
Gdk.threads_leave()
|
2008-09-30 15:08:33 +00:00
|
|
|
|
2010-12-10 23:53:19 +00:00
|
|
|
if isinstance(event, bb.command.CommandCompleted):
|
2008-09-30 15:08:33 +00:00
|
|
|
continue
|
2010-12-17 15:20:39 +00:00
|
|
|
|
2016-10-10 08:30:04 +00:00
|
|
|
if isinstance(event, bb.event.NoProvider):
|
|
|
|
if event._runtime:
|
|
|
|
r = "R"
|
|
|
|
else:
|
|
|
|
r = ""
|
|
|
|
|
|
|
|
extra = ''
|
|
|
|
if not event._reasons:
|
|
|
|
if event._close_matches:
|
|
|
|
extra = ". Close matches:\n %s" % '\n '.join(event._close_matches)
|
|
|
|
|
|
|
|
if event._dependees:
|
2016-11-30 12:43:19 +00:00
|
|
|
print("Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)%s" % (r, event._item, ", ".join(event._dependees), r, extra))
|
2016-10-10 08:30:04 +00:00
|
|
|
else:
|
|
|
|
print("Nothing %sPROVIDES '%s'%s" % (r, event._item, extra))
|
|
|
|
if event._reasons:
|
|
|
|
for reason in event._reasons:
|
|
|
|
print(reason)
|
|
|
|
|
|
|
|
_, error = server.runCommand(["stateShutdown"])
|
|
|
|
if error:
|
|
|
|
print('Unable to cleanly shutdown: %s' % error)
|
|
|
|
break
|
|
|
|
|
2010-12-10 23:53:19 +00:00
|
|
|
if isinstance(event, bb.command.CommandFailed):
|
2010-04-10 02:46:14 +00:00
|
|
|
print("Command execution failed: %s" % event.error)
|
2010-12-10 23:53:19 +00:00
|
|
|
return event.exitcode
|
2010-12-17 15:20:39 +00:00
|
|
|
|
2010-12-10 23:53:19 +00:00
|
|
|
if isinstance(event, bb.command.CommandExit):
|
|
|
|
return event.exitcode
|
2010-12-17 15:20:39 +00:00
|
|
|
|
2010-01-19 14:48:19 +00:00
|
|
|
if isinstance(event, bb.cooker.CookerExit):
|
2008-09-30 15:08:33 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
continue
|
2010-12-17 15:20:39 +00:00
|
|
|
except EnvironmentError as ioerror:
|
|
|
|
# ignore interrupted io
|
|
|
|
if ioerror.args[0] == 4:
|
|
|
|
pass
|
2008-09-30 15:08:33 +00:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
if shutdown == 2:
|
2010-04-10 02:46:14 +00:00
|
|
|
print("\nThird Keyboard Interrupt, exit.\n")
|
2008-09-30 15:08:33 +00:00
|
|
|
break
|
|
|
|
if shutdown == 1:
|
2010-04-10 02:46:14 +00:00
|
|
|
print("\nSecond Keyboard Interrupt, stopping...\n")
|
2013-09-13 16:31:54 +00:00
|
|
|
_, error = server.runCommand(["stateForceShutdown"])
|
bitbake: command: add error to return of runCommand
Currently, command.py can return an error message from runCommand, due to
being unable to run the command, yet few of our UIs (just hob) can handle it
today. This can result in seeing a TypeError with traceback in certain rare
circumstances.
To resolve this, we need a clean way to get errors back from runCommand,
without having to isinstance() the return value. This implements such a thing
by making runCommand also return an error (or None if no error occurred).
As runCommand now has a method of returning errors, we can also alter the
getCmdLineAction bits such that the returned value is just the action, not an
additional message. If a sync command wants to return an error, it raises
CommandError(message), and the message will be passed to the caller
appropriately.
Example Usage:
result, error = server.runCommand(...)
if error:
log.error('Unable to run command: %s' % error)
return 1
(Bitbake rev: 717831b8315cb3904d9b590e633000bc897e8fb6)
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-10-29 20:01:23 +00:00
|
|
|
if error:
|
|
|
|
print('Unable to cleanly stop: %s' % error)
|
2008-09-30 15:08:33 +00:00
|
|
|
if shutdown == 0:
|
2010-04-10 02:46:14 +00:00
|
|
|
print("\nKeyboard Interrupt, closing down...\n")
|
bitbake: command: add error to return of runCommand
Currently, command.py can return an error message from runCommand, due to
being unable to run the command, yet few of our UIs (just hob) can handle it
today. This can result in seeing a TypeError with traceback in certain rare
circumstances.
To resolve this, we need a clean way to get errors back from runCommand,
without having to isinstance() the return value. This implements such a thing
by making runCommand also return an error (or None if no error occurred).
As runCommand now has a method of returning errors, we can also alter the
getCmdLineAction bits such that the returned value is just the action, not an
additional message. If a sync command wants to return an error, it raises
CommandError(message), and the message will be passed to the caller
appropriately.
Example Usage:
result, error = server.runCommand(...)
if error:
log.error('Unable to run command: %s' % error)
return 1
(Bitbake rev: 717831b8315cb3904d9b590e633000bc897e8fb6)
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-10-29 20:01:23 +00:00
|
|
|
_, error = server.runCommand(["stateShutdown"])
|
|
|
|
if error:
|
|
|
|
print('Unable to cleanly shutdown: %s' % error)
|
2008-09-30 15:08:33 +00:00
|
|
|
shutdown = shutdown + 1
|
|
|
|
pass
|