Ticket #37: integrateConfigTester-v3.diff
| File integrateConfigTester-v3.diff, 4.0 kB (added by bhearsum, 10 months ago) |
|---|
-
old-trunk/buildbot/scripts/checkconfig.py
old new 1 import sys 2 import os 3 from shutil import copy, rmtree 4 from tempfile import mkdtemp 5 from os.path import isfile 6 import traceback 7 8 from buildbot import master 9 10 class ConfigLoader(master.BuildMaster): 11 def __init__(self, configFileName="master.cfg"): 12 master.BuildMaster.__init__(self, ".", 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 file = configFileName 18 try: 19 copy(configFileName, tempdir) 20 for entry in os.listdir("."): 21 # Any code in a subdirectory will _not_ be copied! This is a bug 22 if isfile(entry): 23 copy(entry, tempdir) 24 except: 25 raise 26 27 try: 28 os.chdir(tempdir) 29 # Add the temp directory to the library path so local modules work 30 sys.path.append(tempdir) 31 configFile = open(configFileName, "r") 32 self.loadConfig(configFile) 33 except: 34 os.chdir(dir) 35 rmtree(tempdir) 36 raise 37 os.chdir(dir) 38 rmtree(tempdir) 39 40 if __name__ == '__main__': 41 try: 42 if len(sys.argv) > 1: 43 c = ConfigLoader(sys.argv[1]) 44 else: 45 c = ConfigLoader() 46 except IOError: 47 print >> sys.stderr, "Could not open config file" 48 sys.exit(2) 49 except: 50 print >> sys.stderr, "Error in config file:" 51 t, v, tb = sys.exc_info() 52 print >> sys.stderr, traceback.print_exception(t, v, tb) 53 sys.exit(1) -
old-trunk/buildbot/scripts/runner.py
old new 3 3 # N.B.: don't import anything that might pull in a reactor yet. Some of our 4 4 # subcommands want to load modules that need the gtk reactor. 5 5 import os, sys, stat, re, time 6 import traceback 6 7 from twisted.python import usage, util, runtime 7 8 8 9 # this is mostly just a front-end for mktap, twistd, and kill(1), but in the … … 809 810 os.rename(tmpfile, newfile) 810 811 811 812 813 class CheckConfigOptions(usage.Options): 814 optFlags = [ 815 ['quiet', 'q', "Don't display error messages or tracebacks"], 816 ] 817 818 def getSynopsis(self): 819 return "Usage :buildbot checkconfig [configFile]\n" + \ 820 " If not specified, 'master.cfg' will be used as 'configFile'" 821 822 def parseArgs(self, *args): 823 if len(args) >= 1: 824 self['configFile'] = args[0] 825 else: 826 self['configFile'] = 'master.cfg' 827 828 829 def doCheckConfig(config): 830 quiet = config.get('quiet') 831 configFile = config.get('configFile') 832 try: 833 from buildbot.scripts.checkconfig import ConfigLoader 834 ConfigLoader(configFile) 835 except: 836 if not quiet: 837 # Print out the traceback in a nice format 838 t, v, tb = sys.exc_info() 839 traceback.print_exception(t, v, tb) 840 sys.exit(1) 841 842 if not quiet: 843 print "Config file is good!" 844 845 812 846 class Options(usage.Options): 813 847 synopsis = "Usage: buildbot <command> [command options]" 814 848 … … 847 881 ['tryserver', None, TryServerOptions, 848 882 "buildmaster-side 'try' support function, not for users"], 849 883 884 ['checkconfig', None, CheckConfigOptions, 885 "test the validity of a master.cfg config file"], 886 850 887 # TODO: 'watch' 851 888 ] 852 889 … … 906 943 doTry(so) 907 944 elif command == "tryserver": 908 945 doTryServer(so) 946 elif command == "checkconfig": 947 doCheckConfig(so) 909 948 910 949
![[Buildbot Logo]](/trac/chrome/site/header-text-transparent.png)