goggle.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #
  2. # BitBake Graphical GTK User Interface
  3. #
  4. # Copyright (C) 2008 Intel Corporation
  5. #
  6. # Authored by Rob Bradford <rob@linux.intel.com>
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License version 2 as
  10. # published by the Free Software Foundation.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License along
  18. # with this program; if not, write to the Free Software Foundation, Inc.,
  19. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  20. from gi import pygtkcompat
  21. pygtkcompat.enable()
  22. pygtkcompat.enable_gtk(version='3.0')
  23. import gobject
  24. import gtk
  25. import xmlrpc.client
  26. from bb.ui.crumbs.runningbuild import RunningBuildTreeView, RunningBuild
  27. from bb.ui.crumbs.progress import ProgressBar
  28. import queue
  29. def event_handle_idle_func (eventHandler, build, pbar):
  30. # Consume as many messages as we can in the time available to us
  31. event = eventHandler.getEvent()
  32. while event:
  33. build.handle_event (event, pbar)
  34. event = eventHandler.getEvent()
  35. return True
  36. def scroll_tv_cb (model, path, iter, view):
  37. view.scroll_to_cell (path)
  38. # @todo hook these into the GUI so the user has feedback...
  39. def running_build_failed_cb (running_build):
  40. pass
  41. def running_build_succeeded_cb (running_build):
  42. pass
  43. class MainWindow (gtk.Window):
  44. def __init__ (self):
  45. gtk.Window.__init__ (self, gtk.WINDOW_TOPLEVEL)
  46. # Setup tree view and the scrolled window
  47. scrolled_window = gtk.ScrolledWindow ()
  48. self.add (scrolled_window)
  49. self.cur_build_tv = RunningBuildTreeView()
  50. self.connect("delete-event", gtk.main_quit)
  51. self.set_default_size(640, 480)
  52. scrolled_window.add (self.cur_build_tv)
  53. def main (server, eventHandler, params):
  54. gobject.threads_init()
  55. gtk.gdk.threads_init()
  56. window = MainWindow ()
  57. window.show_all ()
  58. pbar = ProgressBar(window)
  59. pbar.connect("delete-event", gtk.main_quit)
  60. # Create the object for the current build
  61. running_build = RunningBuild ()
  62. window.cur_build_tv.set_model (running_build.model)
  63. running_build.model.connect("row-inserted", scroll_tv_cb, window.cur_build_tv)
  64. running_build.connect ("build-succeeded", running_build_succeeded_cb)
  65. running_build.connect ("build-failed", running_build_failed_cb)
  66. try:
  67. params.updateFromServer(server)
  68. cmdline = params.parseActions()
  69. if not cmdline:
  70. print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
  71. return 1
  72. if 'msg' in cmdline and cmdline['msg']:
  73. logger.error(cmdline['msg'])
  74. return 1
  75. cmdline = cmdline['action']
  76. ret, error = server.runCommand(cmdline)
  77. if error:
  78. print("Error running command '%s': %s" % (cmdline, error))
  79. return 1
  80. elif ret != True:
  81. print("Error running command '%s': returned %s" % (cmdline, ret))
  82. return 1
  83. except xmlrpcclient.Fault as x:
  84. print("XMLRPC Fault getting commandline:\n %s" % x)
  85. return 1
  86. # Use a timeout function for probing the event queue to find out if we
  87. # have a message waiting for us.
  88. gobject.timeout_add (100,
  89. event_handle_idle_func,
  90. eventHandler,
  91. running_build,
  92. pbar)
  93. try:
  94. gtk.main()
  95. except EnvironmentError as ioerror:
  96. # ignore interrupted io
  97. if ioerror.args[0] == 4:
  98. pass
  99. except KeyboardInterrupt:
  100. pass
  101. finally:
  102. server.runCommand(["stateForceShutdown"])