summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Boyer <jwboyer@redhat.com>2012-05-08 13:35:32 -0400
committerJosh Boyer <jwboyer@redhat.com>2012-05-08 13:35:32 -0400
commit0c08f9f8efc3e0a7e9cedf307ecabf98ee4b7a76 (patch)
tree4119b035329d5f37c88ee55c6b4f93a269fc0da5
parent5ce31e715154142f12010d9048e2bc22223cb607 (diff)
downloadkoji-bisect-0c08f9f8efc3e0a7e9cedf307ecabf98ee4b7a76.zip
koji-bisect-0c08f9f8efc3e0a7e9cedf307ecabf98ee4b7a76.tar.gz
koji-bisect-0c08f9f8efc3e0a7e9cedf307ecabf98ee4b7a76.tar.xz
Stop storing indexes for good and bad. Use NVR instead.
That was just dumb. The indexes become stale as soon as you alter the builds_left list. Also do a bunch more crap with logging so I can look at the log and have even a glimmer of hope as to what I was thinking
-rwxr-xr-xkoji-bisect.py72
1 files changed, 56 insertions, 16 deletions
diff --git a/koji-bisect.py b/koji-bisect.py
index 0df6da4..d886a16 100755
--- a/koji-bisect.py
+++ b/koji-bisect.py
@@ -165,11 +165,11 @@ def bisect_log(string):
global bisect_log_file
if bisect_log_file == None:
try:
- bisect_log_file = open('.koji-bisect.log', 'w+')
+ bisect_log_file = open('.koji-bisect.log', 'a+')
except:
print "Wtf. No log. Weird."
sys.exit(1)
- bisect_log_file.write(string)
+ bisect_log_file.write(string + "\n")
bisect_log_file.flush()
def bisect_save(data):
@@ -177,10 +177,24 @@ def bisect_save(data):
cPickle.dump(data, dfile)
dfile.flush()
dfile.close()
+ if data['good']:
+ bisect_log("Good build %s" % data['good'])
+
+ if data['bad']:
+ bisect_log("Bad build %s" % data['bad'])
+
+ if data['current']:
+ bisect_log("Current build %s" % data['current'])
+
+ if data['builds_left']:
+ bisect_log("Builds left:")
+ for build in data['builds_left']:
+ bisect_log(build)
def bisect_load():
bisect_data_def = { 'good': None,
'bad': None,
+ 'current' : None,
'builds_left': None }
bisect_data = bisect_data_def
@@ -247,7 +261,9 @@ if __name__ == "__main__":
bisect_log_file = open('.koji-bisect.log', 'w')
bisect_data_file = open('.koji-bisect.data', 'w')
bisect_log_file.close()
- bisect_data_file.close()
+ bisect_log_file = None
+ bisect_data_file.close()
+ bisect_data_file = None
if not args.good and not args.bad:
if args.list:
@@ -256,29 +272,43 @@ if __name__ == "__main__":
sys.exit(0)
else:
print "Must have a good or bad index"
+ bisect_save(bisect_data)
sys.exit(1)
build_list = bisect_data['builds_left']
if args.good:
- i = bisect.bisect_left(build_list, args.good)
- if i != len(build_list) and build_list[i] == args.good:
+ try:
+ i = build_list.index(args.good)
print "Marking %s as good" % build_list[i]
bisect_log("Marking %s as good" % build_list[i])
- bisect_data['good'] = i
- else:
+ bisect_data['good'] = build_list[i]
+
+ except ValueError:
+# i = bisect.bisect_left(build_list, args.good)
+# if i != len(build_list) and build_list[i] == args.good:
+# print "Marking %s as good" % build_list[i]
+# bisect_log("Marking %s as good" % build_list[i])
+# bisect_data['good'] = i
+# else:
print "Invalid build %s. Please pick from list:" % args.good
list_builds(bisect_data['builds_left'])
sys.exit(1)
- bad_index = None
if args.bad:
- i = bisect.bisect_left(build_list, args.bad)
- if i != len(build_list) and build_list[i] == args.bad:
+ try:
+ i = build_list.index(args.bad)
print "Marking %s as bad" % build_list[i]
bisect_log("Marking %s as bad" % build_list[i])
- bisect_data['bad'] = i
- else:
+ bisect_data['bad'] = build_list[i]
+
+ except ValueError:
+# i = bisect.bisect_left(build_list, args.bad)
+# if i != len(build_list) and build_list[i] == args.bad:
+# print "Marking %s as bad" % build_list[i]
+# bisect_log("Marking %s as bad" % build_list[i])
+# bisect_data['bad'] = i
+# else:
print "Invalid build %s. Please pick from list:" % args.good
list_builds(bisect_data['builds_left'])
sys.exit(1)
@@ -292,15 +322,25 @@ if __name__ == "__main__":
if bisect_data['good'] and bisect_data['bad']:
builds_left = bisect_data['builds_left']
- good = bisect_data['good']
- bad = bisect_data['bad']
+ good = builds_left.index(bisect_data['good'])
+ bad = builds_left.index(bisect_data['bad'])
if good < bad:
- builds_left = build_list[good:bad]
+ if len(build_list) == bad:
+ builds_left = build_list[good:]
+ else:
+ builds_left = build_list[good:bad+1]
elif good == bad:
print "Shit yo, is %s bad or good ?!" % build_list[good]
else:
- builds_left = build_list[bad:good]
+ if len(build_list) == good:
+ builds_left = build_list[bad:]
+ else:
+ builds_left = build_list[bad:good+1]
+
bisect_data['builds_left'] = builds_left
+ bisect_data['current'] = builds_left[len(builds_left)/2]
+
+ print builds_left[len(builds_left)/2]
bisect_save(bisect_data)