in src/manager.py [0:0]
def readCommandLine(self):
sname = "scripts/server/serverinfo.xml"
dname = "scripts/tests"
fnames = []
ssl = False
all = False
excludes = set()
subdir = None
pidfile = "../CalendarServer/logs/caldavd.pid"
random_order = False
random_seed = str(random.randint(0, 1000000))
observer_names = []
options, args = getopt.getopt(
sys.argv[1:],
"s:mo:x:",
[
"ssl",
"all",
"basedir=",
"subdir=",
"exclude=",
"pretest=",
"posttest=",
"observer=",
"pid=",
"postgres-log=",
"random",
"random-seed=",
"stop",
"print-details-onfail",
"always-print-request",
"always-print-response",
"debug"
],
)
# Process single options
for option, value in options:
if option == "-s":
sname = value
elif option == "-x":
dname = value
elif option == "--ssl":
ssl = True
elif option == "--all":
all = True
elif option == "--basedir":
self.base_dir = value
sname = os.path.join(self.base_dir, "serverinfo.xml")
dname = os.path.join(self.base_dir, "tests")
self.data_dir = os.path.join(self.base_dir, "data")
# Also add parent to PYTHON path
sys.path.append(os.path.dirname(self.base_dir))
elif option == "--subdir":
subdir = value + "/"
elif option == "--exclude":
excludes.add(value)
elif option == "--pretest":
self.pretest = value
elif option == "--posttest":
self.posttest = value
elif option == "-m":
self.memUsage = True
elif option == "-o":
self.logFile = open(value, "w")
elif option == "--pid":
pidfile = value
elif option == "--observer":
observer_names.append(value)
elif option == "--postgres-log":
self.postgresLog = value
elif option == "--stop":
self.stoponfail = True
elif option == "--print-details-onfail":
self.print_request_response_on_error = True
elif option == "--always-print-request":
self.print_request = True
elif option == "--always-print-response":
self.print_response = True
elif option == "--random":
random_order = True
elif option == "--random-seed":
random_seed = value
elif option == "--debug":
self.debug = True
if all or not args:
files = []
os.path.walk(dname, lambda arg, dir, names: files.extend([os.path.join(dir, name) for name in names]) if not dir.startswith("test") else None, None)
for file in files:
if file.endswith(".xml") and file[len(dname) + 1:] not in excludes:
if subdir is None or file[len(dname) + 1:].startswith(subdir):
fnames.append(file)
# Remove any server info file from files enumerated by --all
fnames[:] = [x for x in fnames if (x != sname)]
def _normPath(f):
# paths starting with . or .. or /
if f[0] in ('.', '/'):
f = os.path.abspath(f)
# remove unneeded leading path
fsplit = f.split(dname)
if 2 == len(fsplit):
f = dname + fsplit[1]
# relative paths
else:
f = os.path.join(dname, f)
return f
# Process any file arguments as test configs
for f in args:
fnames.append(_normPath(f))
if self.pretest is not None:
self.pretest = _normPath(self.pretest)
if self.posttest is not None:
self.posttest = _normPath(self.posttest)
# Randomize file list
if random_order and len(fnames) > 1:
random.seed(random_seed)
random.shuffle(fnames)
self.randomSeed = random_seed
# Load observers
map(lambda name: self.loadObserver(name), observer_names if observer_names else ["log", ])
self.readXML(sname, fnames, ssl, all)
if self.memUsage:
fd = open(pidfile, "r")
s = fd.read()
self.pid = int(s)