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.inlineCallbacks
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 yield self.debug_registration.unregister() 47 self.debug_registration = None 48 49 if new_config.debugPassword and config_changed: 50 factory = lambda mind, user : DebugPerspective(self.master) 51 self.debug_registration = self.master.pbmanager.register( 52 new_config.slavePortnum, "debug", new_config.debugPassword, 53 factory) 54 55 self.debug_password = new_config.debugPassword 56 if self.debug_password: 57 self.debug_port = new_config.slavePortnum 58 else: 59 self.debug_port = None 60 61 # manhole 62 if new_config.manhole != self.manhole: 63 if self.manhole: 64 yield defer.maybeDeferred(lambda : 65 self.manhole.disownServiceParent()) 66 self.manhole.master = None 67 self.manhole = None 68 69 if new_config.manhole: 70 self.manhole = new_config.manhole 71 self.manhole.master = self.master 72 self.manhole.setServiceParent(self) 73 74 # chain up 75 yield config.ReconfigurableServiceMixin.reconfigService(self, 76 new_config)
77 78 79 @defer.inlineCallbacks
80 - def stopService(self):
81 if self.debug_registration: 82 yield self.debug_registration.unregister() 83 self.debug_registration = None 84 85 # manhole will get stopped as a sub-service 86 87 yield defer.maybeDeferred(lambda : 88 service.MultiService.stopService(self)) 89 90 # clean up 91 if self.manhole: 92 self.manhole.master = None 93 self.manhole = None
94
95 96 -class DebugPerspective(NewCredPerspective):
97
98 - def __init__(self, master):
99 self.master = master
100
101 - def attached(self, mind):
102 return self
103
104 - def detached(self, mind):
105 pass
106
107 - def perspective_requestBuild(self, buildername, reason, branch, 108 revision, properties={}):
109 c = interfaces.IControl(self.master) 110 bc = c.getBuilder(buildername) 111 ss = SourceStamp(branch, revision) 112 bpr = Properties() 113 bpr.update(properties, "remote requestBuild") 114 return bc.submitBuildRequest(ss, reason, bpr)
115
116 - def perspective_pingBuilder(self, buildername):
117 c = interfaces.IControl(self.master) 118 bc = c.getBuilder(buildername) 119 bc.ping()
120
121 - def perspective_reload(self):
122 log.msg("debug client - triggering master reconfig") 123 self.master.reconfig()
124
125 - def perspective_pokeIRC(self):
126 log.msg("saying something on IRC") 127 from buildbot.status import words 128 for s in self.master: 129 if isinstance(s, words.IRC): 130 bot = s.f 131 for channel in bot.channels: 132 print " channel", channel 133 bot.p.msg(channel, "Ow, quit it")
134
135 - def perspective_print(self, msg):
136 log.msg("debug %s" % msg)
137