Option parser returns : Command set to run on each (or all) machines, port to connect to server, List of machines to connect to, File to pickle results to, Dictionary to index which command set to use for which machine.
24 def _isValidPerfCmdsDef(alist):
27 isdict = isinstance(item, type({}))
31 out = out
and key
in validPerfSuitKeys
33 out = out
and isinstance(item[key], type(
""))
35 out = out
and isinstance(item[key], type(
""))
36 elif key ==
"castordir":
37 out = out
and isinstance(item[key], type(
""))
38 elif key ==
"perfsuitedir":
39 out = out
and isinstance(item[key], type(
""))
40 elif key ==
"TimeSizeEvents":
41 out = out
and isinstance(item[key], type(123))
42 elif key ==
"TimeSizeCandles":
43 out = out
and isinstance(item[key], type(
""))
44 elif key ==
"CallgrindEvents":
45 out = out
and isinstance(item[key], type(123))
46 elif key ==
"CallgrindCandles":
47 out = out
and isinstance(item[key], type(
""))
48 elif key ==
"IgProfEvents":
49 out = out
and isinstance(item[key], type(123))
50 elif key ==
"IgProfCandles":
51 out = out
and isinstance(item[key], type(
""))
52 elif key ==
"MemcheckEvents":
53 out = out
and isinstance(item[key], type(123))
54 elif key ==
"MemcheckCandles":
55 out = out
and isinstance(item[key], type(
""))
56 elif key ==
"cmsScimark":
57 out = out
and isinstance(item[key], type(123))
58 elif key ==
"cmsScimarkLarge":
59 out = out
and isinstance(item[key], type(123))
60 elif key ==
"cmsdriverOptions":
61 out = out
and isinstance(item[key], type(
""))
62 elif key ==
"stepOptions":
63 out = out
and isinstance(item[key], type(
""))
64 elif key ==
"quicktest":
65 out = out
and isinstance(item[key], type(
False))
66 elif key ==
"profilers":
67 out = out
and isinstance(item[key], type(
""))
68 elif key ==
"prevrel":
69 out = out
and isinstance(item[key], type(
""))
70 elif key ==
"isAllCandles":
71 out = out
and isinstance(item[key], type(
False))
72 elif key ==
"candles":
73 out = out
and isinstance(item[key], type(
""))
74 elif key ==
"bypasshlt":
75 out = out
and isinstance(item[key], type(
False))
76 elif key ==
"runonspare":
77 out = out
and isinstance(item[key], type(
False))
78 elif key ==
"logfile":
79 out = out
and isinstance(item[key], type(
""))
82 parser = opt.OptionParser(usage=(
"""%s [Options]""" % PROG_NAME))
84 parser.add_option(
'-p',
89 help=
'Connect to server on a particular port',
93 parser.add_option(
'-o',
98 help=
'File to output data to',
102 parser.add_option(
'-m',
108 help=
'Machines to run the benchmarking on, for each machine add another one of these options',
109 metavar=
'<MACHINES>',
112 parser.add_option(
'-f',
118 help=
'A files of cmsPerfSuite.py commands to execute on the machines, if more than one of these options is passed and the number of these options is the same as the number of machines, the x-th machine will use the x-th config file.',
122 (options, args) = parser.parse_args()
127 outfile = options.outfile
128 if not outfile ==
"":
129 outfile = os.path.abspath(options.outfile)
130 outdir = os.path.dirname(outfile)
131 if not os.path.isdir(outdir):
132 parser.error(
"ERROR: %s is not a valid directory to create %s" % (outdir,os.path.basename(outfile)))
135 outfile = os.path.join(os.getcwd(),
"cmsmultiperfdata.pypickle")
137 if os.path.exists(outfile):
138 parser.error(
"ERROR: outfile %s already exists" % outfile)
146 cmscmdfiles = options.cmscmdfile
147 if len(cmscmdfiles) <= 0:
148 parser.error(
"A valid python file defining a list of dictionaries that represents a list of cmsPerfSuite keyword arguments must be passed to this program")
151 for cmscmdfile
in cmscmdfiles:
152 cmdfile = os.path.abspath(cmscmdfile)
154 if os.path.isfile(cmdfile):
157 cmsperf_cmds.append(listperfsuitekeywords)
158 except (SyntaxError)
as detail:
159 parser.error(
"ERROR: %s must be a valid python file" % cmdfile)
161 except (NameError)
as detail:
162 parser.error(
"ERROR: %s must contain a list (variable named listperfsuitekeywords) of dictionaries that represents a list of cmsPerfSuite keyword arguments must be passed to this program: %s" % (cmdfile,
str(detail)))
166 if not isinstance(cmsperf_cmds[-1], type([])):
167 parser.error(
"ERROR: %s must contain a list (variable named listperfsuitekeywords) of dictionaries that represents a list of cmsPerfSuite keyword arguments must be passed to this program 2" % cmdfile)
169 if not _isValidPerfCmdsDef(cmsperf_cmds[-1]):
170 parser.error(
"ERROR: %s must contain a list (variable named listperfsuitekeywords) of dictionaries that represents a list of cmsPerfSuite keyword arguments must be passed to this program 3" % cmdfile)
174 parser.error(
"ERROR: %s is not a file" % cmdfile)
181 if options.port == -1:
186 machines = options.machines
191 if len(machines) <= 0:
192 parser.error(
"you must specify at least one machine to benchmark")
194 machines =
map(
lambda x: x.strip(),machines)
196 for machine
in machines:
198 output = socket.getaddrinfo(machine,port)
199 except socket.gaierror:
200 parser.error(
"ERROR: Can not resolve machine address %s (must be ip{4,6} or hostname)" % machine)
207 if len(cmsperf_cmds) == 1:
208 for machine
in machines:
211 cmdindex[machine] = 0
213 if not len(cmsperf_cmds) == len(machines):
214 parser.error(
"if more than one configuration file was specified you must specify a configuration file for each machine.")
217 for i
in range(len(machines)):
220 cmdindex[machine] = i
222 return (cmsperf_cmds, port, machines, outfile, cmdindex)
def optionparse()
Option parser returns : Command set to run on each (or all) machines, port to connect to server...