1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
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
39
40
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
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
81 wfd = defer.waitForDeferred(
82 config.ReconfigurableServiceMixin.reconfigService(self,
83 new_config))
84 yield wfd
85 wfd.getResult()
86
87
88 @defer.deferredGenerator
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
98
99 wfd = defer.waitForDeferred(
100 defer.maybeDeferred(lambda :
101 service.MultiService.stopService(self)))
102 yield wfd
103 wfd.getResult()
104
105
106 if self.manhole:
107 self.manhole.master = None
108 self.manhole = None
109
112
115
118
121
130
135
139
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
151 log.msg("debug %s" % msg)
152