def _failure(self, why): if why.check(BuildmasterTimeoutError): print(rewrap("""\ The buildmaster took more than 10 seconds to start, so we were unable to confirm that it started correctly. Please 'tail twistd.log' and look for a line that says 'BuildMaster is running' to verify correct startup. """)) elif why.check(ReconfigError): print(rewrap("""\ The buildmaster appears to have encountered an error in the master.cfg config file during startup. Please inspect and fix master.cfg, then restart the buildmaster. """)) elif why.check(BuildmasterStartupError): print(rewrap("""\ The buildmaster startup failed. Please see 'twistd.log' for possible reason. """)) else: print(rewrap("""\ Unable to confirm that the buildmaster started correctly. You may need to stop it, fix the config file, and restart. """)) print(why) self.rc = 1 reactor.stop()
def test_main(self): tests = [ ("", "", None), ("\n", "\n", None), ("\n ", "\n", None), (" \n", "\n", None), (" \n ", "\n", None), (""" multiline with indent """, "\nmultiline with indent", None), ("""\ multiline with indent """, "multiline with indent\n", None), ("""\ multiline with indent """, "multiline with indent\n", None), ("""\ multiline with indent and formatting """, "multiline with indent\n and\n formatting\n", None), ("""\ multiline with indent and wrapping and formatting """, "multiline with\nindent and\nwrapping\n and\n formatting\n", 15), ] for text, expected, width in tests: self.assertEqual(util.rewrap(text, width=width), expected)
def failure(self, why): self.rc = 1 if why.check(BuildmasterTimeoutError): print("Never saw reconfiguration finish.") elif why.check(ReconfigError): print(rewrap("""\ Reconfiguration failed. Please inspect the master.cfg file for errors, correct them, then try 'buildbot reconfig' again. """)) elif why.check(IOError): # we were probably unable to open the file in the first place self.sighup() else: print("Error while following twistd.log: %s" % why)
def run(self, basedir, quiet, timeout=None): # Returns "Microsoft" for Vista and "Windows" for other versions if platform.system() in ("Windows", "Microsoft"): print("Reconfig (through SIGHUP) is not supported on Windows.") return None with open(os.path.join(basedir, "twistd.pid"), "rt", encoding='utf-8') as f: self.pid = int(f.read().strip()) if quiet: os.kill(self.pid, signal.SIGHUP) return None # keep reading twistd.log. Display all messages between "loading # configuration from ..." and "configuration update complete" or # "I will keep using the previous config file instead.", or until # `timeout` seconds have elapsed. self.sent_signal = False reactor.callLater(0.2, self.sighup) lw = LogWatcher(os.path.join(basedir, "twistd.log"), timeout=timeout) try: yield lw.start() print("Reconfiguration appears to have completed successfully") return 0 except BuildmasterTimeoutError: print("Never saw reconfiguration finish.") except ReconfigError: print( rewrap("""\ Reconfiguration failed. Please inspect the master.cfg file for errors, correct them, then try 'buildbot reconfig' again. """)) except IOError: # we were probably unable to open the file in the first place self.sighup() except Exception as e: print(f"Error while following twistd.log: {e}") return 1