summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Boyer <jwboyer@redhat.com>2012-05-08 15:07:25 -0400
committerJosh Boyer <jwboyer@redhat.com>2012-05-08 15:07:25 -0400
commit47a3ed8d04decea4261f85247b24e97198e16274 (patch)
tree86de82e7b89669c63204bd8c998f81fb84bfcd8b
parent0c08f9f8efc3e0a7e9cedf307ecabf98ee4b7a76 (diff)
downloadkoji-bisect-47a3ed8d04decea4261f85247b24e97198e16274.zip
koji-bisect-47a3ed8d04decea4261f85247b24e97198e16274.tar.gz
koji-bisect-47a3ed8d04decea4261f85247b24e97198e16274.tar.xz
Actually download stuff. Consolidate stuff.
Create a mark_build function so I can duplicate less code. Yay or something. Copy download_build from koji (sigh). Actually call it and download the "current" build.
-rwxr-xr-xkoji-bisect.py88
1 files changed, 57 insertions, 31 deletions
diff --git a/koji-bisect.py b/koji-bisect.py
index d886a16..5811a72 100755
--- a/koji-bisect.py
+++ b/koji-bisect.py
@@ -9,6 +9,7 @@ import os
import bisect
from functools import cmp_to_key
import cPickle
+import urlgrabber.grabber as grabber
class Options:
debug = True
@@ -115,6 +116,46 @@ def activate_session(session):
if options.debug:
print "successfully connected to hub"
+# This is copied almost directly from koji. Sigh again.
+def download_build(session, build):
+ info = session.getBuild(build)
+
+ if info is None:
+ print "No such build: %s" % build
+ print "Email Josh because he messed up somewhere."
+ sys.exit(1)
+
+ rpms = session.listRPMs(buildID=info['id'], arches='x86_64')
+ if not rpms:
+ print "No packages available for %s" % koji.buildLabel(info)
+ sys.exit(1)
+
+ urls = []
+ for rpm in rpms:
+ # Skip debuginfo because it's huge
+ if koji.is_debuginfo(rpm['name']):
+ continue
+
+ fname = koji.pathinfo.rpm(rpm)
+ url = '%s/%s/%s/%s/%s' % (options.pkgurl, info['name'], info['version'], info['release'], fname)
+ urls.append((url, os.path.basename(fname)))
+
+ for url, relpath in urls:
+ file = grabber.urlopen(url, text=relpath)
+
+ if '/' in relpath:
+ koji.ensuredir(os.path.dirname(relpath))
+ out = os.open(relpath, os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 0666)
+ try:
+ while 1:
+ buf = file.read(4096)
+ if not buf:
+ break
+ os.write(out, buf)
+ finally:
+ os.close(out)
+ file.close()
+
# Everything above this line is all koji session bullshit that we shouldn't
# have to copy, but do because koji doesn't put it in a damn module somewhere
# ANGRY CODING
@@ -212,6 +253,15 @@ def bisect_load():
dfile.close()
return bisect_data
+def mark_build(build_list, build, goodbad):
+ try:
+ i = build_list.index(build)
+ print "Marking %s as %s" % (build_list[i], goodbad)
+ bisect_log("Marking %s as %s" % (build_list[i], goodbad))
+ return build
+ except ValueError:
+ raise
+
if __name__ == "__main__":
global options
options = Options()
@@ -238,9 +288,10 @@ if __name__ == "__main__":
bisect_data = bisect_load()
+ session = koji.ClientSession(options.server)
+ activate_session(session)
+
if bisect_data['builds_left'] == None:
- session = koji.ClientSession(options.server)
- activate_session(session)
all_builds = session.listBuilds(packageID=8, state=1)
@@ -279,47 +330,22 @@ if __name__ == "__main__":
if 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'] = build_list[i]
+ bisect_data['good'] = mark_build(build_list, args.good, "good")
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)
if 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'] = build_list[i]
+ bisect_data['bad'] = mark_build(build_list, args.bad, "bad")
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
+ print "Invalid build %s. Please pick from list:" % args.bad
list_builds(bisect_data['builds_left'])
sys.exit(1)
-# 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 = builds_left.index(bisect_data['good'])
@@ -340,7 +366,7 @@ if __name__ == "__main__":
bisect_data['builds_left'] = builds_left
bisect_data['current'] = builds_left[len(builds_left)/2]
- print builds_left[len(builds_left)/2]
+ download_build(session, builds_left[len(builds_left)/2])
bisect_save(bisect_data)