summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Boyer <jwboyer@redhat.com>2012-05-08 12:13:29 -0400
committerJosh Boyer <jwboyer@redhat.com>2012-05-08 12:13:29 -0400
commit5ce31e715154142f12010d9048e2bc22223cb607 (patch)
treea55fbef6f948b97423d7ed044281055c4f329b8e
parent1536a5f6277b003424cac6966734d722e7496c8d (diff)
downloadkoji-bisect-5ce31e715154142f12010d9048e2bc22223cb607.zip
koji-bisect-5ce31e715154142f12010d9048e2bc22223cb607.tar.gz
koji-bisect-5ce31e715154142f12010d9048e2bc22223cb607.tar.xz
Start saving data. Start actually trying to narrow down the list of kernels.
So much crap code still, but at least it isn't all pointless
-rwxr-xr-xkoji-bisect.py148
1 files changed, 124 insertions, 24 deletions
diff --git a/koji-bisect.py b/koji-bisect.py
index 8262d95..0df6da4 100755
--- a/koji-bisect.py
+++ b/koji-bisect.py
@@ -8,6 +8,7 @@ import koji
import os
import bisect
from functools import cmp_to_key
+import cPickle
class Options:
debug = True
@@ -23,6 +24,8 @@ class Options:
user = None
runas = None
+bisect_log_file = None
+
def get_options():
global options
# load local config
@@ -149,6 +152,8 @@ def get_args():
parser.add_argument('--bad', action='store', help='bad kernel NVR')
parser.add_argument('--list', action='store_true', help='list of builds remaining')
parser.add_argument('--dist', action='store', help='disttag of specific release')
+ parser.add_argument('--start', action='store_true', help='start bisecting')
+ parser.add_argument('--reset', action='store_true', help='cancel bisecting')
return parser.parse_args()
@@ -156,6 +161,43 @@ def list_builds(builds):
for build in builds:
print build
+def bisect_log(string):
+ global bisect_log_file
+ if bisect_log_file == None:
+ try:
+ bisect_log_file = open('.koji-bisect.log', 'w+')
+ except:
+ print "Wtf. No log. Weird."
+ sys.exit(1)
+ bisect_log_file.write(string)
+ bisect_log_file.flush()
+
+def bisect_save(data):
+ dfile = open('.koji-bisect.data', 'w')
+ cPickle.dump(data, dfile)
+ dfile.flush()
+ dfile.close()
+
+def bisect_load():
+ bisect_data_def = { 'good': None,
+ 'bad': None,
+ 'builds_left': None }
+
+ bisect_data = bisect_data_def
+
+ try:
+ dfile = open('.koji-bisect.data', 'r')
+ except:
+ return bisect_data
+
+ try:
+ bisect_data = cPickle.load(dfile)
+ except:
+ bisect_data = bisect_data_def
+
+ dfile.close()
+ return bisect_data
+
if __name__ == "__main__":
global options
options = Options()
@@ -164,46 +206,104 @@ if __name__ == "__main__":
args = get_args()
- session = koji.ClientSession(options.server)
- activate_session(session)
+ if args.reset:
+ if args.start or args.good or args.bad:
+ print "Can't reset and specify something else too"
+ sys.exit(1)
+
+ # Clear out the files. We dont' care if they didn't exist
+ try:
+ os.remove('.koji-bisect.log')
+ except:
+ pass
+ try:
+ os.remove('.koji-bisect.data')
+ except:
+ pass
+ sys.exit(0)
- all_builds = session.listBuilds(packageID=8, state=1)
- print all_builds[0]
+ bisect_data = bisect_load()
- builds = all_builds
- if args.dist:
- builds = filter_dist(builds, args.dist)
+ if bisect_data['builds_left'] == None:
+ session = koji.ClientSession(options.server)
+ activate_session(session)
- build_list = sort_builds(builds)
- builds_left = build_list
+ all_builds = session.listBuilds(packageID=8, state=1)
+
+ builds = all_builds
+ if args.dist:
+ builds = filter_dist(builds, args.dist)
+
+ build_list = sort_builds(builds)
+ builds_left = build_list
+
+ bisect_data['builds_left'] = builds_left
+
+ if args.start:
+ if os.path.exists('.koji-bisect.log') or os.path.exists('.koji-bisect.data'):
+ print "Koji-bisect already in progress. Please reset with --reset"
+ sys.exit(1)
+ else:
+ bisect_log_file = open('.koji-bisect.log', 'w')
+ bisect_data_file = open('.koji-bisect.data', 'w')
+ bisect_log_file.close()
+ bisect_data_file.close()
+
+ if not args.good and not args.bad:
+ if args.list:
+ list_builds(bisect_data['builds_left'])
+ bisect_save(bisect_data)
+ sys.exit(0)
+ else:
+ print "Must have a good or bad index"
+ sys.exit(1)
+
+ build_list = bisect_data['builds_left']
- good_index = None
if args.good:
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]
- good_index = 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:
print "Marking %s as bad" % build_list[i]
- bad_index = 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)
- if good_index == None or bad_index == None:
- if args.list:
- list_builds(builds_left)
+# if bisect_data['good'] == None and bisect_data['bad'] == None:
+# if args.list:
+# list_builds(bisect_data['builds_left'])
+# else:
+# print "Must have a good or bad index"
+# sys.exit(1)
+
+ if bisect_data['good'] and bisect_data['bad']:
+ builds_left = bisect_data['builds_left']
+ good = bisect_data['good']
+ bad = bisect_data['bad']
+ if good < bad:
+ builds_left = build_list[good:bad]
+ elif good == bad:
+ print "Shit yo, is %s bad or good ?!" % build_list[good]
else:
- print "Must have a good or bad index"
- sys.exit(1)
+ builds_left = build_list[bad:good]
+ bisect_data['builds_left'] = builds_left
+
+ bisect_save(bisect_data)
- if good_index < bad_index:
- builds_left = build_list[good_index:bad_index]
- elif good_index == bad_index:
- print "Shit yo, is %s bad or good ?!" % build_list[good_index]
- else:
- builds_left = build_list[bad_index:good_index]
if args.list:
- list_builds(builds_left)
+ list_builds(bisect_data['builds_left'])