@@ -156,24 +156,28 @@ def resource_path(relative_path):
156156def validate_perfargs (perf ):
157157 """validate perf command before executing"""
158158 if perf [0 ] != "perf" :
159- raise SystemExit ("Not a perf command, exiting!" )
159+ log .error ("Not a perf command, exiting!" )
160+ sys .exit (1 )
160161
161162
162163def validate_file (fname ):
163164 """validate if file is accessible"""
164165 if not os .access (fname , os .R_OK ):
165- raise SystemExit (str (fname ) + " not accessible" )
166+ log .error (str (fname ) + " not accessible" )
167+ sys .exit (1 )
166168
167169
168170def is_safe_file (fname , substr ):
169171 """verify if file name/format is accurate"""
170172 if not fname .endswith (substr ):
171- raise SystemExit (str (fname ) + " isn't appropriate format" )
173+ log .error (str (fname ) + " isn't appropriate format" )
174+ sys .exit (1 )
172175
173176
174177if __name__ == "__main__" :
175178 if platform .system () != "Linux" :
176- raise SystemExit ("PerfSpect currently supports Linux only" )
179+ log .error ("PerfSpect currently supports Linux only" )
180+ sys .exit (1 )
177181
178182 # fix the pyinstaller path
179183 script_path = os .path .dirname (os .path .realpath (__file__ ))
@@ -278,9 +282,10 @@ def is_safe_file(fname, substr):
278282 procinfo = perf_helpers .get_cpuinfo ()
279283 arch , cpuname = perf_helpers .get_arch_and_name (procinfo )
280284 if not arch :
281- raise SystemExit (
285+ log . error (
282286 f"Unrecognized CPU architecture. Supported architectures: { ', ' .join (SUPPORTED_ARCHITECTURES )} "
283287 )
288+ sys .exit (1 )
284289 eventfile = None
285290 if arch == "broadwell" :
286291 eventfile = "bdx.txt"
@@ -303,7 +308,8 @@ def is_safe_file(fname, substr):
303308 eventfile = script_path + "/events/" + eventfile
304309 eventfilename = eventfile
305310 else :
306- raise SystemExit ("Unknown application type" )
311+ log .error ("Unknown application type" )
312+ sys .exit (1 )
307313
308314 if args .outcsv == default_output_file :
309315 # create results dir
@@ -312,9 +318,10 @@ def is_safe_file(fname, substr):
312318 perf_helpers .fix_path_ownership (result_dir )
313319 else :
314320 if not perf_helpers .validate_outfile (args .outcsv ):
315- raise SystemExit (
321+ log . error (
316322 "Output filename not accepted. Filename should be a .csv without special characters"
317323 )
324+ sys .exit (1 )
318325
319326 mux_intervals = perf_helpers .get_perf_event_mux_interval ()
320327 if args .muxinterval > 0 :
@@ -404,13 +411,6 @@ def is_safe_file(fname, substr):
404411 args .outcsv ,
405412 args .timeout ,
406413 )
407- elif args .dryrun :
408- cmd = "perf stat %s -I %d -x , -e %s -o %s sleep 10" % (
409- collection_type ,
410- interval ,
411- events ,
412- args .outcsv ,
413- )
414414 else :
415415 cmd = "perf stat %s -I %d -x , -e %s -o %s" % (
416416 collection_type ,
0 commit comments