2011-11-28 06:32:40 +00:00
|
|
|
#!/usr/bin/env python
|
2011-02-02 13:02:43 +00:00
|
|
|
#
|
|
|
|
# BitBake Graphical GTK User Interface
|
|
|
|
#
|
|
|
|
# Copyright (C) 2011 Intel Corporation
|
|
|
|
#
|
|
|
|
# Authored by Joshua Lock <josh@linux.intel.com>
|
2011-11-28 06:32:40 +00:00
|
|
|
# Authored by Dongxiao Xu <dongxiao.xu@intel.com>
|
2011-02-02 13:02:43 +00:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2011-11-28 06:32:40 +00:00
|
|
|
import sys
|
|
|
|
import os
|
2012-04-05 17:56:43 +00:00
|
|
|
requirements = "FATAL: Gtk+, PyGtk and PyGobject are required to use Hob"
|
2012-04-04 00:35:41 +00:00
|
|
|
try:
|
|
|
|
import gobject
|
|
|
|
import gtk
|
|
|
|
import pygtk
|
|
|
|
pygtk.require('2.0') # to be certain we don't have gtk+ 1.x !?!
|
2012-04-05 17:56:43 +00:00
|
|
|
gtkver = gtk.gtk_version
|
|
|
|
pygtkver = gtk.pygtk_version
|
|
|
|
if gtkver < (2, 18, 0) or pygtkver < (2, 16, 0):
|
|
|
|
sys.exit("%s,\nYou have Gtk+ %s and PyGtk %s." % (requirements,
|
|
|
|
".".join(map(str, gtkver)),
|
|
|
|
".".join(map(str, pygtkver))))
|
2012-04-04 00:35:41 +00:00
|
|
|
except ImportError as exc:
|
|
|
|
sys.exit("%s (%s)." % (requirements, str(exc)))
|
2011-11-28 06:32:40 +00:00
|
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
|
|
|
try:
|
|
|
|
import bb
|
|
|
|
except RuntimeError as exc:
|
|
|
|
sys.exit(str(exc))
|
|
|
|
from bb.ui import uihelper
|
|
|
|
from bb.ui.crumbs.hoblistmodel import RecipeListModel, PackageListModel
|
2011-02-02 13:02:43 +00:00
|
|
|
from bb.ui.crumbs.hobeventhandler import HobHandler
|
2011-11-28 06:32:40 +00:00
|
|
|
from bb.ui.crumbs.builder import Builder
|
2011-02-02 13:02:43 +00:00
|
|
|
|
2011-06-03 00:21:44 +00:00
|
|
|
extraCaches = ['bb.cache_extra:HobRecipeInfo']
|
|
|
|
|
2011-11-28 06:32:40 +00:00
|
|
|
def event_handle_idle_func(eventHandler, hobHandler):
|
|
|
|
# Consume as many messages as we can in the time available to us
|
|
|
|
if not eventHandler:
|
2011-07-01 22:58:50 +00:00
|
|
|
return False
|
2011-11-28 06:32:40 +00:00
|
|
|
event = eventHandler.getEvent()
|
|
|
|
while event:
|
|
|
|
hobHandler.handle_event(event)
|
|
|
|
event = eventHandler.getEvent()
|
|
|
|
return True
|
|
|
|
|
|
|
|
def main (server = None, eventHandler = None):
|
2011-02-02 13:02:43 +00:00
|
|
|
gobject.threads_init()
|
|
|
|
|
2011-11-28 06:32:40 +00:00
|
|
|
# That indicates whether the Hob and the bitbake server are
|
|
|
|
# running on different machines
|
|
|
|
# recipe model and package model
|
|
|
|
recipe_model = RecipeListModel()
|
|
|
|
package_model = PackageListModel()
|
2011-09-02 21:29:38 +00:00
|
|
|
|
2012-03-19 03:08:45 +00:00
|
|
|
hobHandler = HobHandler(server, recipe_model, package_model)
|
2011-11-28 06:32:40 +00:00
|
|
|
builder = Builder(hobHandler, recipe_model, package_model)
|
2011-02-02 13:02:43 +00:00
|
|
|
|
|
|
|
# This timeout function regularly probes the event queue to find out if we
|
|
|
|
# have any messages waiting for us.
|
2011-11-28 06:32:40 +00:00
|
|
|
gobject.timeout_add(10, event_handle_idle_func, eventHandler, hobHandler)
|
2011-02-02 13:02:43 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
gtk.main()
|
|
|
|
except EnvironmentError as ioerror:
|
|
|
|
# ignore interrupted io
|
|
|
|
if ioerror.args[0] == 4:
|
|
|
|
pass
|
|
|
|
finally:
|
2011-11-28 06:32:40 +00:00
|
|
|
hobHandler.cancel_build(force = True)
|
2011-02-02 13:02:43 +00:00
|
|
|
|
2011-11-28 06:32:40 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
try:
|
|
|
|
ret = main()
|
|
|
|
except Exception:
|
|
|
|
ret = 1
|
|
|
|
import traceback
|
|
|
|
traceback.print_exc(15)
|
|
|
|
sys.exit(ret)
|