goggle.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. import gobject
  21. import gtk
  22. import xmlrpclib
  23. from bb.ui.crumbs.runningbuild import RunningBuildTreeView, RunningBuild
  24. from bb.ui.crumbs.progress import ProgressBar
  25. import Queue
  26. def event_handle_idle_func (eventHandler, build, pbar):
  27. # Consume as many messages as we can in the time available to us
  28. event = eventHandler.getEvent()
  29. while event:
  30. build.handle_event (event, pbar)
  31. event = eventHandler.getEvent()
  32. return True
  33. def scroll_tv_cb (model, path, iter, view):
  34. view.scroll_to_cell (path)
  35. # @todo hook these into the GUI so the user has feedback...
  36. def running_build_failed_cb (running_build):
  37. pass
  38. def running_build_succeeded_cb (running_build):
  39. pass
  40. class MainWindow (gtk.Window):
  41. def __init__ (self):
  42. gtk.Window.__init__ (self, gtk.WINDOW_TOPLEVEL)
  43. # Setup tree view and the scrolled window
  44. scrolled_window = gtk.ScrolledWindow ()
  45. self.add (scrolled_window)
  46. self.cur_build_tv = RunningBuildTreeView()
  47. self.connect("delete-event", gtk.main_quit)
  48. self.set_default_size(640, 480)
  49. scrolled_window.add (self.cur_build_tv)
  50. def main (server, eventHandler):
  51. gobject.threads_init()
  52. gtk.gdk.threads_init()
  53. window = MainWindow ()
  54. window.show_all ()
  55. pbar = ProgressBar(window)
  56. pbar.connect("delete-event", gtk.main_quit)
  57. # Create the object for the current build
  58. running_build = RunningBuild ()
  59. window.cur_build_tv.set_model (running_build.model)
  60. running_build.model.connect("row-inserted", scroll_tv_cb, window.cur_build_tv)
  61. running_build.connect ("build-succeeded", running_build_succeeded_cb)
  62. running_build.connect ("build-failed", running_build_failed_cb)
  63. try:
  64. cmdline, error = server.runCommand(["getCmdLineAction"])
  65. if err:
  66. print("Error getting bitbake commandline: %s" % error)
  67. return 1
  68. elif not cmdline:
  69. print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
  70. return 1
  71. ret, error = server.runCommand(cmdline)
  72. if error:
  73. print("Error running command '%s': %s" % (cmdline, error))
  74. return 1
  75. elif ret != True:
  76. print("Error running command '%s': returned %s" % (cmdline, ret))
  77. return 1
  78. except xmlrpclib.Fault as x:
  79. print("XMLRPC Fault getting commandline:\n %s" % x)
  80. return 1
  81. # Use a timeout function for probing the event queue to find out if we
  82. # have a message waiting for us.
  83. gobject.timeout_add (100,
  84. event_handle_idle_func,
  85. eventHandler,
  86. running_build,
  87. pbar)
  88. try:
  89. gtk.main()
  90. except EnvironmentError as ioerror:
  91. # ignore interrupted io
  92. if ioerror.args[0] == 4:
  93. pass
  94. except KeyboardInterrupt:
  95. pass
  96. finally:
  97. server.runCommand(["stateStop"])