6 from optparse import OptionParser
14 print "Downloading %s" %url
15 request = urllib2.Request(url)
16 base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
17 request.add_header("Authorization", "Basic %s" % base64string)
18 html_page = urllib2.urlopen(request)
21 def download(url, out):
23 if not os.path.exists(out):
24 cache = open(out, "w")
25 cache.write(ret.read())
28 def get_package_lists2(image_name, base_url, build_id):
29 cache_file = "cache/%s-%s.packages" %(image_name, build_id )
31 if not os.path.exists(cache_file):
32 image_packages = "%s/%s/images/%s/%s-%s.packages" %(base_url, build_id, image_name, image_name, build_id )
33 package_file = http_get(image_packages)
34 cache = open(cache_file, "w")
35 cache.write(package_file.read())
38 package_file = open(cache_file, "rb")
42 pkgreader = csv.reader(package_file, delimiter=' ', quotechar='|')
44 pkg = row[0].split(".")
45 name = "%s-%s.%s" %(pkg[0], row[1], pkg[1])
51 def get_package_lists(image_name, base_url, build_id):
52 cache_file = "cache/%s-%s.packages" %(image_name, build_id )
54 if not os.path.exists(cache_file):
55 image_packages = "%s/%s/images/%s/%s-%s.packages" %(base_url, build_id, image_name, image_name, build_id )
57 package_file = http_get(image_packages)
58 cache = open(cache_file, "w")
59 cache.write(package_file.read())
62 package_file = open(cache_file, "rb")
66 pkgreader = csv.reader(package_file, delimiter=' ', quotechar='|')
68 pkg = row[0].split(".")
70 packages[pkg[0]] = {'scm': row[2], 'version': row[1], 'arch': pkg[1]}
72 packages[pkg[0]] = {'scm': None, 'version': row[1], 'arch': pkg[1]}
77 parser = OptionParser()
78 parser.add_option("-o", "--old", dest="old", metavar="OLD", help="Old snapshot")
79 parser.add_option("-n", "--new", dest="new", metavar="NEW", help="New snapshot")
80 parser.add_option("-t", "--type", dest="type", metavar="TYPE", help="Release type")
81 parser.add_option("-i", "--image", dest="image", metavar="IMAGE", help="Image Name")
83 (options, args) = parser.parse_args()
85 DAILY="/pc/releases/daily/trunk"
86 WEEKLY="/pc/releases/weekly/trunk"
87 SNAPSHOTS="/snapshots/trunk/pc/"
88 BASE="https://download.tz.otcshare.org/"
90 if options.type == "daily":
91 release_url = "%s/%s" %(BASE, DAILY)
92 if options.type == "weekly":
93 release_url = "%s/%s" %(BASE, WEEKLY)
95 release_url = "%s/%s" %(BASE, SNAPSHOTS)
97 p1 = get_package_lists2(options.image, release_url, options.old)
98 p2 = get_package_lists2(options.image, release_url, options.new)
100 diff = Set(p2).difference(Set(p1))
102 print "Fetching %s" %p
104 download("%s/%s/repos/pc/x86_64/packages/noarch/%s.rpm" %(release_url, options.new, p), "%s.rpm" %p)
106 download("%s/%s/repos/pc/x86_64/packages/x86_64/%s.rpm" %(release_url, options.new, p), "%s.rpm" %p)