1   
 2  import os, signal, platform 
 3  from twisted.internet import reactor 
 4   
 5  from buildbot.scripts.logwatcher import LogWatcher, BuildmasterTimeoutError, \ 
 6       ReconfigError 
 7   
 9 -    def run(self, config): 
 10           
11          if platform.system() in ("Windows", "Microsoft"): 
12              print "Reconfig (through SIGHUP) is not supported on Windows." 
13              print "The 'buildbot debugclient' tool can trigger a reconfig" 
14              print "remotely, but requires Gtk+ libraries to run." 
15              return 
16   
17          basedir = config['basedir'] 
18          quiet = config['quiet'] 
19          os.chdir(basedir) 
20          f = open("twistd.pid", "rt") 
21          self.pid = int(f.read().strip()) 
22          if quiet: 
23              os.kill(self.pid, signal.SIGHUP) 
24              return 
25   
26           
27           
28           
29           
30   
31          self.sent_signal = False 
32          lw = LogWatcher("twistd.log") 
33          d = lw.start() 
34          d.addCallbacks(self.success, self.failure) 
35          reactor.callLater(0.2, self.sighup) 
36          reactor.run() 
 37   
39          if self.sent_signal: 
40              return 
41          print "sending SIGHUP to process %d" % self.pid 
42          self.sent_signal = True 
43          os.kill(self.pid, signal.SIGHUP) 
 44   
46          print """ 
47  Reconfiguration appears to have completed successfully. 
48  """ 
49          reactor.stop() 
 50   
52          if why.check(BuildmasterTimeoutError): 
53              print "Never saw reconfiguration finish." 
54          elif why.check(ReconfigError): 
55              print """ 
56  Reconfiguration failed. Please inspect the master.cfg file for errors, 
57  correct them, then try 'buildbot reconfig' again. 
58  """ 
59          elif why.check(IOError): 
60               
61              self.sighup() 
62          else: 
63              print "Error while following twistd.log: %s" % why 
64          reactor.stop() 
  65   
69