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