"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "buildbot/scripts/reconfig.py" between
buildbot-3.0.2.tar.gz and buildbot-3.1.0.tar.gz

About: Buildbot is a continuous integration testing framework (Python-based). It supports also automation of complex build systems, application deployment, and management of sophisticated software-release processes.

reconfig.py  (buildbot-3.0.2):reconfig.py  (buildbot-3.1.0)
skipping to change at line 20 skipping to change at line 20
# You should have received a copy of the GNU General Public License along with # You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51 # this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
# Copyright Buildbot Team Members # Copyright Buildbot Team Members
import os import os
import platform import platform
import signal import signal
from twisted.internet import defer
from twisted.internet import reactor from twisted.internet import reactor
from buildbot.scripts.logwatcher import BuildmasterTimeoutError from buildbot.scripts.logwatcher import BuildmasterTimeoutError
from buildbot.scripts.logwatcher import LogWatcher from buildbot.scripts.logwatcher import LogWatcher
from buildbot.scripts.logwatcher import ReconfigError from buildbot.scripts.logwatcher import ReconfigError
from buildbot.util import in_reactor from buildbot.util import in_reactor
from buildbot.util import rewrap from buildbot.util import rewrap
class Reconfigurator: class Reconfigurator:
rc = 0 @defer.inlineCallbacks
def run(self, basedir, quiet, timeout=None):
def run(self, basedir, quiet):
# Returns "Microsoft" for Vista and "Windows" for other versions # Returns "Microsoft" for Vista and "Windows" for other versions
if platform.system() in ("Windows", "Microsoft"): if platform.system() in ("Windows", "Microsoft"):
print("Reconfig (through SIGHUP) is not supported on Windows.") print("Reconfig (through SIGHUP) is not supported on Windows.")
return None return None
with open(os.path.join(basedir, "twistd.pid"), "rt") as f: with open(os.path.join(basedir, "twistd.pid"), "rt") as f:
self.pid = int(f.read().strip()) self.pid = int(f.read().strip())
if quiet: if quiet:
os.kill(self.pid, signal.SIGHUP) os.kill(self.pid, signal.SIGHUP)
return None return None
# keep reading twistd.log. Display all messages between "loading # keep reading twistd.log. Display all messages between "loading
# configuration from ..." and "configuration update complete" or # configuration from ..." and "configuration update complete" or
# "I will keep using the previous config file instead.", or until # "I will keep using the previous config file instead.", or until
# 10 seconds have elapsed. # `timeout` seconds have elapsed.
self.sent_signal = False self.sent_signal = False
reactor.callLater(0.2, self.sighup) reactor.callLater(0.2, self.sighup)
lw = LogWatcher(os.path.join(basedir, "twistd.log")) lw = LogWatcher(os.path.join(basedir, "twistd.log"), timeout=timeout)
d = lw.start()
d.addCallbacks(self.success, self.failure)
d.addBoth(lambda _: self.rc)
return d
def sighup(self):
if self.sent_signal:
return
print("sending SIGHUP to process %d" % self.pid)
self.sent_signal = True
os.kill(self.pid, signal.SIGHUP)
def success(self, res):
print("Reconfiguration appears to have completed successfully")
def failure(self, why): try:
self.rc = 1 yield lw.start()
if why.check(BuildmasterTimeoutError): print("Reconfiguration appears to have completed successfully")
return 0
except BuildmasterTimeoutError:
print("Never saw reconfiguration finish.") print("Never saw reconfiguration finish.")
elif why.check(ReconfigError): except ReconfigError:
print(rewrap("""\ print(rewrap("""\
Reconfiguration failed. Please inspect the master.cfg file for Reconfiguration failed. Please inspect the master.cfg file for
errors, correct them, then try 'buildbot reconfig' again. errors, correct them, then try 'buildbot reconfig' again.
""")) """))
elif why.check(IOError): except IOError:
# we were probably unable to open the file in the first place # we were probably unable to open the file in the first place
self.sighup() self.sighup()
else: except Exception as e:
print("Error while following twistd.log: {}".format(why)) print("Error while following twistd.log: {}".format(e))
return 1
def sighup(self):
if self.sent_signal:
return
print("sending SIGHUP to process %d" % self.pid)
self.sent_signal = True
os.kill(self.pid, signal.SIGHUP)
@in_reactor @in_reactor
def reconfig(config): def reconfig(config):
basedir = config['basedir'] basedir = config['basedir']
quiet = config['quiet'] quiet = config['quiet']
timeout = config.get('progress_timeout', None)
if timeout is not None:
try:
timeout = float(timeout)
except ValueError:
print('Progress timeout must be a number')
return 1
r = Reconfigurator() r = Reconfigurator()
return r.run(basedir, quiet) return r.run(basedir, quiet, timeout=timeout)
 End of changes. 10 change blocks. 
26 lines changed or deleted 32 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)