Package buildbot :: Package scripts :: Module checkconfig
[frames] | no frames]

Source Code for Module buildbot.scripts.checkconfig

 1  # This file is part of Buildbot.  Buildbot is free software: you can 
 2  # redistribute it and/or modify it under the terms of the GNU General Public 
 3  # License as published by the Free Software Foundation, version 2. 
 4  # 
 5  # This program is distributed in the hope that it will be useful, but WITHOUT 
 6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
 8  # details. 
 9  # 
10  # You should have received a copy of the GNU General Public License along with 
11  # this program; if not, write to the Free Software Foundation, Inc., 51 
12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
13  # 
14  # Copyright Buildbot Team Members 
15   
16  import sys 
17  import os 
18  from shutil import copy, rmtree 
19  from tempfile import mkdtemp 
20  from os.path import isfile 
21   
22  from buildbot import master 
23   
24 -class ConfigLoader(master.BuildMaster):
25 - def __init__(self, basedir=os.getcwd(), configFileName="master.cfg"):
26 master.BuildMaster.__init__(self, basedir, configFileName) 27 configFileName = os.path.join(basedir, configFileName) 28 dir = os.getcwd() 29 # Use a temporary directory since loadConfig() creates a bunch of 30 # directories and compiles .py files 31 tempdir = mkdtemp() 32 try: 33 copy(configFileName, tempdir) 34 for entry in os.listdir("."): 35 # Any code in a subdirectory will _not_ be copied! This is a bug 36 if isfile(entry) and not entry.startswith("twistd.log"): 37 copy(entry, tempdir) 38 except: 39 raise 40 41 try: 42 os.chdir(tempdir) 43 # Add the temp directory to the library path so local modules work 44 sys.path.append(tempdir) 45 configFile = open(configFileName, "r") 46 self.loadConfig(configFile, check_synchronously_only=True) 47 except: 48 # clean up before passing on the exception 49 os.chdir(dir) 50 rmtree(tempdir) 51 raise 52 os.chdir(dir) 53 rmtree(tempdir)
54