mirror of
https://git.yoctoproject.org/poky
synced 2026-02-20 08:29:42 +01:00
Add code so the uihelper keeps track of how may tasks we've run and how many tasks there are in total so UIs don't have to track this information themselves. (Bitbake rev: 17e68cfc6018b93d19738a6a874dfdea23fbab11) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
94 lines
3.6 KiB
Python
94 lines
3.6 KiB
Python
# ex:ts=4:sw=4:sts=4:et
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
#
|
|
# Copyright (C) 2006 - 2007 Michael 'Mickey' Lauer
|
|
# Copyright (C) 2006 - 2007 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.
|
|
|
|
import bb.build
|
|
|
|
class BBUIHelper:
|
|
def __init__(self):
|
|
self.needUpdate = False
|
|
self.running_tasks = {}
|
|
self.failed_tasks = []
|
|
self.tasknumber_current = 0
|
|
self.tasknumber_total = 0
|
|
|
|
def eventHandler(self, event):
|
|
if isinstance(event, bb.build.TaskStarted):
|
|
self.running_tasks[event.pid] = { 'title' : "%s %s" % (event._package, event._task) }
|
|
self.needUpdate = True
|
|
if isinstance(event, bb.build.TaskSucceeded):
|
|
del self.running_tasks[event.pid]
|
|
self.needUpdate = True
|
|
if isinstance(event, bb.build.TaskFailedSilent):
|
|
del self.running_tasks[event.pid]
|
|
# Don't add to the failed tasks list since this is e.g. a setscene task failure
|
|
self.needUpdate = True
|
|
if isinstance(event, bb.build.TaskFailed):
|
|
del self.running_tasks[event.pid]
|
|
self.failed_tasks.append( { 'title' : "%s %s" % (event._package, event._task)})
|
|
self.needUpdate = True
|
|
if isinstance(event, bb.runqueue.runQueueTaskStarted):
|
|
self.tasknumber_current = event.stats.completed + event.stats.active + event.stats.failed + 1
|
|
self.tasknumber_total = event.stats.total
|
|
|
|
def getTasks(self):
|
|
self.needUpdate = False
|
|
return (self.running_tasks, self.failed_tasks)
|
|
|
|
def findServerDetails(self):
|
|
import sys
|
|
import optparse
|
|
from bb.server.xmlrpc import BitbakeServerInfo, BitBakeServerConnection
|
|
host = ""
|
|
port = 0
|
|
bind = ""
|
|
parser = optparse.OptionParser(
|
|
usage = """%prog -H host -P port -B bindaddr""")
|
|
|
|
parser.add_option("-H", "--host", help = "Bitbake server's IP address",
|
|
action = "store", dest = "host", default = None)
|
|
|
|
parser.add_option("-P", "--port", help = "Bitbake server's Port number",
|
|
action = "store", dest = "port", default = None)
|
|
|
|
parser.add_option("-B", "--bind", help = "Hob2 local bind address",
|
|
action = "store", dest = "bind", default = None)
|
|
|
|
options, args = parser.parse_args(sys.argv)
|
|
for key, val in options.__dict__.items():
|
|
if key == 'host' and val:
|
|
host = val
|
|
elif key == 'port' and val:
|
|
port = int(val)
|
|
elif key == 'bind' and val:
|
|
bind = val
|
|
|
|
if not host or not port or not bind:
|
|
parser.print_usage()
|
|
sys.exit(1)
|
|
|
|
serverinfo = BitbakeServerInfo(host, port)
|
|
clientinfo = (bind, 0)
|
|
connection = BitBakeServerConnection(serverinfo, clientinfo)
|
|
|
|
server = connection.connection
|
|
eventHandler = connection.events
|
|
|
|
return server, eventHandler, host, bind
|
|
|