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

Source Code for Module buildbot.process.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  from twisted.python import log 
 17  from twisted.internet import defer 
 18  from twisted.application import service 
 19  from buildbot.pbutil import NewCredPerspective 
 20  from buildbot.sourcestamp import SourceStamp 
 21  from buildbot import interfaces, config 
 22  from buildbot.process.properties import Properties 
23 24 -class DebugServices(config.ReconfigurableServiceMixin, service.MultiService):
25
26 - def __init__(self, master):
27 service.MultiService.__init__(self) 28 self.setName('debug_services') 29 self.master = master 30 31 self.debug_port = None 32 self.debug_password = None 33 self.debug_registration = None 34 self.manhole = None
35 36 37 @defer.deferredGenerator
38 - def reconfigService(self, new_config):
39 40 # debug client 41 config_changed = (self.debug_port != new_config.slavePortnum or 42 self.debug_password != new_config.debugPassword) 43 44 if not new_config.debugPassword or config_changed: 45 if self.debug_registration: 46 wfd = defer.waitForDeferred( 47 self.debug_registration.unregister()) 48 yield wfd 49 wfd.getResult() 50 self.debug_registration = None 51 52 if new_config.debugPassword and config_changed: 53 factory = lambda mind, user : DebugPerspective(self.master) 54 self.debug_registration = self.master.pbmanager.register( 55 new_config.slavePortnum, "debug", new_config.debugPassword, 56 factory) 57 58 self.debug_password = new_config.debugPassword 59 if self.debug_password: 60 self.debug_port = new_config.slavePortnum 61 else: 62 self.debug_port = None 63 64 # manhole 65 if new_config.manhole != self.manhole: 66 if self.manhole: 67 wfd = defer.waitForDeferred( 68 defer.maybeDeferred(lambda : 69 self.manhole.disownServiceParent())) 70 yield wfd 71 wfd.getResult() 72 self.manhole.master = None 73 self.manhole = None 74 75 if new_config.manhole: 76 self.manhole = new_config.manhole 77 self.manhole.master = self.master 78 self.manhole.setServiceParent(self) 79 80 # chain up 81 wfd = defer.waitForDeferred( 82 config.ReconfigurableServiceMixin.reconfigService(self, 83 new_config)) 84 yield wfd 85 wfd.getResult()
86 87 88 @defer.deferredGenerator
89 - def stopService(self):
90 if self.debug_registration: 91 wfd = defer.waitForDeferred( 92 self.debug_registration.unregister()) 93 yield wfd 94 wfd.getResult() 95 self.debug_registration = None 96 97 # manhole will get stopped as a sub-service 98 99 wfd = defer.waitForDeferred( 100 defer.maybeDeferred(lambda : 101 service.MultiService.stopService(self))) 102 yield wfd 103 wfd.getResult() 104 105 # clean up 106 if self.manhole: 107 self.manhole.master = None 108 self.manhole = None
109
110 111 -class DebugPerspective(NewCredPerspective):
112
113 - def __init__(self, master):
114 self.master = master
115
116 - def attached(self, mind):
117 return self
118
119 - def detached(self, mind):
120 pass
121
122 - def perspective_requestBuild(self, buildername, reason, branch, 123 revision, properties={}):
124 c = interfaces.IControl(self.master) 125 bc = c.getBuilder(buildername) 126 ss = SourceStamp(branch, revision) 127 bpr = Properties() 128 bpr.update(properties, "remote requestBuild") 129 return bc.submitBuildRequest(ss, reason, bpr)
130
131 - def perspective_pingBuilder(self, buildername):
132 c = interfaces.IControl(self.master) 133 bc = c.getBuilder(buildername) 134 bc.ping()
135
136 - def perspective_reload(self):
137 log.msg("debug client - triggering master reconfig") 138 self.master.reconfig()
139
140 - def perspective_pokeIRC(self):
141 log.msg("saying something on IRC") 142 from buildbot.status import words 143 for s in self.master: 144 if isinstance(s, words.IRC): 145 bot = s.f 146 for channel in bot.channels: 147 print " channel", channel 148 bot.p.msg(channel, "Ow, quit it")
149
150 - def perspective_print(self, msg):
151 log.msg("debug %s" % msg)
152