summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/buildstats-diff38
1 files changed, 21 insertions, 17 deletions
diff --git a/scripts/buildstats-diff b/scripts/buildstats-diff
index f26a6c139e..3c6cb1e27c 100755
--- a/scripts/buildstats-diff
+++ b/scripts/buildstats-diff
@@ -30,6 +30,11 @@ logging.basicConfig(level=logging.INFO)
30log = logging.getLogger() 30log = logging.getLogger()
31 31
32 32
33class ScriptError(Exception):
34 """Exception for internal error handling of this script"""
35 pass
36
37
33class TimeZone(tzinfo): 38class TimeZone(tzinfo):
34 """Simple fixed-offset tzinfo""" 39 """Simple fixed-offset tzinfo"""
35 def __init__(self, seconds, name): 40 def __init__(self, seconds, name):
@@ -161,8 +166,7 @@ def read_buildstats_dir(bs_dir):
161 log.warning("Multiple buildstats found, using the first one") 166 log.warning("Multiple buildstats found, using the first one")
162 top_dir = subdirs[0] 167 top_dir = subdirs[0]
163 else: 168 else:
164 log.error("No such directory: %s", bs_dir) 169 raise ScriptError("No such directory: {}".format(bs_dir))
165 sys.exit(1)
166 log.debug("Reading buildstats directory %s", top_dir) 170 log.debug("Reading buildstats directory %s", top_dir)
167 subdirs = os.listdir(top_dir) 171 subdirs = os.listdir(top_dir)
168 172
@@ -187,9 +191,8 @@ def read_buildstats_dir(bs_dir):
187 recipe_bs['tasks'][task] = read_buildstats_file( 191 recipe_bs['tasks'][task] = read_buildstats_file(
188 os.path.join(recipe_dir, task)) 192 os.path.join(recipe_dir, task))
189 if name in buildstats: 193 if name in buildstats:
190 log.error("Cannot handle multiple versions of the same package (%s)", 194 raise ScriptError("Cannot handle multiple versions of the same "
191 name) 195 "package ({})".format(name))
192 sys.exit(1)
193 buildstats[name] = recipe_bs 196 buildstats[name] = recipe_bs
194 197
195 return buildstats 198 return buildstats
@@ -202,9 +205,8 @@ def read_buildstats_json(path):
202 bs_json = json.load(fobj) 205 bs_json = json.load(fobj)
203 for recipe_bs in bs_json: 206 for recipe_bs in bs_json:
204 if recipe_bs['name'] in buildstats: 207 if recipe_bs['name'] in buildstats:
205 log.error("Cannot handle multiple versions of the same package (%s)", 208 raise ScriptError("Cannot handle multiple versions of the same "
206 recipe_bs['name']) 209 "package ({})".format(recipe_bs['name']))
207 sys.exit(1)
208 210
209 if recipe_bs['epoch'] is None: 211 if recipe_bs['epoch'] is None:
210 recipe_bs['nevr'] = "{}-{}-{}".format(recipe_bs['name'], recipe_bs['version'], recipe_bs['revision']) 212 recipe_bs['nevr'] = "{}-{}-{}".format(recipe_bs['name'], recipe_bs['version'], recipe_bs['revision'])
@@ -497,16 +499,18 @@ def main(argv=None):
497 sys.exit(1) 499 sys.exit(1)
498 sort_by.append(field) 500 sort_by.append(field)
499 501
502 try:
503 bs1 = read_buildstats(args.buildstats1)
504 bs2 = read_buildstats(args.buildstats2)
500 505
501 bs1 = read_buildstats(args.buildstats1) 506 if args.ver_diff:
502 bs2 = read_buildstats(args.buildstats2) 507 print_ver_diff(bs1, bs2)
503 508 else:
504 if args.ver_diff: 509 print_task_diff(bs1, bs2, args.diff_attr, args.min_val,
505 print_ver_diff(bs1, bs2) 510 args.min_absdiff, sort_by)
506 else: 511 except ScriptError as err:
507 print_task_diff(bs1, bs2, args.diff_attr, args.min_val, 512 log.error(str(err))
508 args.min_absdiff, sort_by) 513 return 1
509
510 return 0 514 return 0
511 515
512if __name__ == "__main__": 516if __name__ == "__main__":