Package buildbot :: Package clients :: Module debug
[frames] | no frames]

Source Code for Module buildbot.clients.debug

  1  # This file is part of Buildbot.  Buildbot is free software: you can 
  2  # redistribute it and/or modify it under the terms of the GNU General Public 
  3  # License as published by the Free Software Foundation, version 2. 
  4  # 
  5  # This program is distributed in the hope that it will be useful, but WITHOUT 
  6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
  7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
  8  # details. 
  9  # 
 10  # You should have received a copy of the GNU General Public License along with 
 11  # this program; if not, write to the Free Software Foundation, Inc., 51 
 12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
 13  # 
 14  # Copyright Buildbot Team Members 
 15   
 16   
 17  from twisted.internet import gtk2reactor 
 18  gtk2reactor.install() 
 19  from twisted.internet import reactor 
 20  from twisted.python import util 
 21  from twisted.spread import pb 
 22  from twisted.cred import credentials 
 23  import gtk.glade #@UnresolvedImport 
 24  import re 
 25   
26 -class DebugWidget:
27 - def __init__(self, master="localhost:8007", passwd="debugpw"):
28 self.connected = 0 29 try: 30 host, port = re.search(r'(.+):(\d+)', master).groups() 31 except: 32 print "unparseable master location '%s'" % master 33 print " expecting something more like localhost:8007" 34 raise 35 self.host = host 36 self.port = int(port) 37 self.passwd = passwd 38 self.remote = None 39 xml = self.xml = gtk.glade.XML(util.sibpath(__file__, "debug.glade")) 40 g = xml.get_widget 41 self.buildname = g('buildname') 42 self.filename = g('filename') 43 self.connectbutton = g('connectbutton') 44 self.connectlabel = g('connectlabel') 45 g('window1').connect('destroy', lambda win: gtk.main_quit()) 46 # put the master info in the window's titlebar 47 g('window1').set_title("Buildbot Debug Tool: %s" % master) 48 c = xml.signal_connect 49 c('do_connect', self.do_connect) 50 c('do_reload', self.do_reload) 51 c('do_rebuild', self.do_rebuild) 52 c('do_poke_irc', self.do_poke_irc) 53 c('do_build', self.do_build) 54 c('do_ping', self.do_ping) 55 c('do_commit', self.do_commit) 56 c('on_usebranch_toggled', self.usebranch_toggled) 57 self.usebranch_toggled(g('usebranch')) 58 c('on_userevision_toggled', self.userevision_toggled) 59 self.userevision_toggled(g('userevision')) 60 c('do_current_offline', self.do_current, "offline") 61 c('do_current_idle', self.do_current, "idle") 62 c('do_current_waiting', self.do_current, "waiting") 63 c('do_current_building', self.do_current, "building")
64
65 - def do_connect(self, widget):
66 if self.connected: 67 self.connectlabel.set_text("Disconnecting...") 68 if self.remote: 69 self.remote.broker.transport.loseConnection() 70 else: 71 self.connectlabel.set_text("Connecting...") 72 f = pb.PBClientFactory() 73 creds = credentials.UsernamePassword("debug", self.passwd) 74 d = f.login(creds) 75 reactor.connectTCP(self.host, int(self.port), f) 76 d.addCallbacks(self.connect_complete, self.connect_failed)
77 - def connect_complete(self, ref):
78 self.connectbutton.set_label("Disconnect") 79 self.connectlabel.set_text("Connected") 80 self.connected = 1 81 self.remote = ref 82 self.remote.callRemote("print", "hello cleveland") 83 self.remote.notifyOnDisconnect(self.disconnected)
84 - def connect_failed(self, why):
85 self.connectlabel.set_text("Failed") 86 print why
87 - def disconnected(self, ref):
88 self.connectbutton.set_label("Connect") 89 self.connectlabel.set_text("Disconnected") 90 self.connected = 0 91 self.remote = None
92
93 - def do_reload(self, widget):
94 if not self.remote: 95 return 96 d = self.remote.callRemote("reload") 97 d.addErrback(self.err)
98 - def do_rebuild(self, widget):
99 print "Not yet implemented" 100 return
101 - def do_poke_irc(self, widget):
102 if not self.remote: 103 return 104 d = self.remote.callRemote("pokeIRC") 105 d.addErrback(self.err)
106
107 - def do_build(self, widget):
108 if not self.remote: 109 return 110 name = self.buildname.get_text() 111 branch = None 112 if self.xml.get_widget("usebranch").get_active(): 113 branch = self.xml.get_widget('branch').get_text() 114 if branch == '': 115 branch = None 116 revision = None 117 if self.xml.get_widget("userevision").get_active(): 118 revision = self.xml.get_widget('revision').get_text() 119 if revision == '': 120 revision = None 121 reason = "debugclient 'Request Build' button pushed" 122 properties = {} 123 d = self.remote.callRemote("requestBuild", 124 name, reason, branch, revision, properties) 125 d.addErrback(self.err)
126
127 - def do_ping(self, widget):
128 if not self.remote: 129 return 130 name = self.buildname.get_text() 131 d = self.remote.callRemote("pingBuilder", name) 132 d.addErrback(self.err)
133
134 - def usebranch_toggled(self, widget):
135 rev = self.xml.get_widget('branch') 136 if widget.get_active(): 137 rev.set_sensitive(True) 138 else: 139 rev.set_sensitive(False)
140
141 - def userevision_toggled(self, widget):
142 rev = self.xml.get_widget('revision') 143 if widget.get_active(): 144 rev.set_sensitive(True) 145 else: 146 rev.set_sensitive(False)
147
148 - def do_commit(self, widget):
149 if not self.remote: 150 return 151 filename = self.filename.get_text() 152 who = self.xml.get_widget("who").get_text() 153 154 branch = None 155 if self.xml.get_widget("usebranch").get_active(): 156 branch = self.xml.get_widget('branch').get_text() 157 if branch == '': 158 branch = None 159 160 revision = None 161 if self.xml.get_widget("userevision").get_active(): 162 revision = self.xml.get_widget('revision').get_text() 163 try: 164 revision = int(revision) 165 except ValueError: 166 pass 167 if revision == '': 168 revision = None 169 170 kwargs = { 'revision': revision, 'who': who } 171 if branch: 172 kwargs['branch'] = branch 173 d = self.remote.callRemote("fakeChange", filename, **kwargs) 174 d.addErrback(self.err)
175
176 - def do_current(self, widget, state):
177 if not self.remote: 178 return 179 name = self.buildname.get_text() 180 d = self.remote.callRemote("setCurrentState", name, state) 181 d.addErrback(self.err)
182 - def err(self, failure):
183 print "received error:", failure
184
185 - def run(self):
186 reactor.run()
187