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

Source Code for Module buildbot.scripts.checkconfig

 1  import sys 
 2  import os 
 3  from shutil import copy, rmtree 
 4  from tempfile import mkdtemp 
 5  from os.path import isfile 
 6   
 7  from buildbot import master 
 8   
9 -class ConfigLoader(master.BuildMaster):
10 - def __init__(self, basedir=os.getcwd(), configFileName="master.cfg"):
11 master.BuildMaster.__init__(self, basedir, configFileName) 12 configFileName = os.path.join(basedir, configFileName) 13 dir = os.getcwd() 14 # Use a temporary directory since loadConfig() creates a bunch of 15 # directories and compiles .py files 16 tempdir = mkdtemp() 17 try: 18 copy(configFileName, tempdir) 19 for entry in os.listdir("."): 20 # Any code in a subdirectory will _not_ be copied! This is a bug 21 if isfile(entry) and not entry.startswith("twistd.log"): 22 copy(entry, tempdir) 23 except: 24 raise 25 26 try: 27 os.chdir(tempdir) 28 # Add the temp directory to the library path so local modules work 29 sys.path.append(tempdir) 30 configFile = open(configFileName, "r") 31 self.loadConfig(configFile, check_synchronously_only=True) 32 except: 33 os.chdir(dir) 34 configFile.close() 35 rmtree(tempdir) 36 raise 37 os.chdir(dir) 38 rmtree(tempdir)
39