Skip to content

Commit

Permalink
include basedir in sys.path during checkconfig
Browse files Browse the repository at this point in the history
This eliminates the need to copy all of the files in the configuration
directory into a temporary directory.  Fixes #1928.
  • Loading branch information
djmitche committed Apr 17, 2011
1 parent e1a03cb commit e2d9ba7
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions master/buildbot/scripts/checkconfig.py
Expand Up @@ -17,7 +17,6 @@
import os
from shutil import copy, rmtree
from tempfile import mkdtemp
from os.path import isfile
from twisted.internet import defer
from buildbot import master

Expand All @@ -33,17 +32,14 @@ def load(self):

def loadcfg(_):
# Use a temporary directory since loadConfig() creates a bunch of
# directories and compiles .py files
# builder directories
self.tempdir = mkdtemp()
copy(self.configFileName, self.tempdir)
for entry in os.listdir("."):
# Any code in a subdirectory will _not_ be copied! This is a bug
if isfile(entry) and not entry.startswith("twistd.log"):
copy(entry, self.tempdir)

os.chdir(self.tempdir)
# Add the temp directory to the library path so local modules work
sys.path.append(self.tempdir)
# Add the original directory to the library path so local module
# imports work
sys.path.append(self.basedir)

bmaster = master.BuildMaster(self.basedir, self.configFileName)
return bmaster.loadConfig(open(self.configFileName, "r"), checkOnly=True)
Expand Down

0 comments on commit e2d9ba7

Please sign in to comment.