Merge ~pfsmorigo/ubuntu-qa-tools:iso_search into ubuntu-qa-tools:master

Proposed by Paulo Flabiano Smorigo
Status: Merged
Approved by: Paulo Flabiano Smorigo
Approved revision: 176ed9e0d2feffdb9ed8f52d6b709ffa98a6ba4b
Merge reported by: Paulo Flabiano Smorigo
Merged at revision: 176ed9e0d2feffdb9ed8f52d6b709ffa98a6ba4b
Proposed branch: ~pfsmorigo/ubuntu-qa-tools:iso_search
Merge into: ubuntu-qa-tools:master
Diff against target: 60 lines (+20/-15)
1 file modified
vm-tools/uvt (+20/-15)
Reviewer Review Type Date Requested Status
Marc Deslauriers Approve
Review via email: mp+393571@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

looks reasonable, ack!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/vm-tools/uvt b/vm-tools/uvt
index 0d5d198..5932cd8 100755
--- a/vm-tools/uvt
+++ b/vm-tools/uvt
@@ -2795,14 +2795,15 @@ def locate_release_iso(release, release_num, arch, iso_type, force):
2795 iso_type = "mini"2795 iso_type = "mini"
27962796
2797 # Try and find the latest point release2797 # Try and find the latest point release
2798 # FIXME: this should list the directory instead of guessing2798 if iso_type == "server" and float(release_num) >= 20.04:
2799 for r in [".7", ".6", ".5", ".4", ".3", ".2", ".1", ""]:2799 match_iso = "ubuntu-{}(|.[0-9])-legacy-{}-{}.iso".format(release_num, iso_type, arch)
2800 if iso_type == "server" and float(release_num) >= 20.04:2800 else:
2801 release_iso = "ubuntu-%s%s-legacy-%s-%s.iso" % (release_num, r, iso_type, arch)2801 match_iso = "ubuntu-{}(|.[0-9])-{}-{}.iso".format(release_num, iso_type, arch)
2802 else:2802
2803 release_iso = "ubuntu-%s%s-%s-%s.iso" % (release_num, r, iso_type, arch)2803 matches = [f for f in os.listdir(uvt_conf['vm_dir_iso']) if re.search(match_iso, f)]
2804 #print "looking for %s" % release_iso2804 if len(matches) > 0:
2805 iso_path = os.path.join(uvt_conf['vm_dir_iso'],release_iso)2805 release_iso = sorted(matches)[-1]
2806 iso_path = os.path.join(uvt_conf['vm_dir_iso'], release_iso)
2806 if os.path.exists(iso_path):2807 if os.path.exists(iso_path):
2807 # iso image is there, but we don't have read access2808 # iso image is there, but we don't have read access
2808 # this sometimes happens when libvirt mucks with the2809 # this sometimes happens when libvirt mucks with the
@@ -2811,7 +2812,7 @@ def locate_release_iso(release, release_num, arch, iso_type, force):
2811 print("Found iso at '%s',\nbut you don't have read permission!\n" % iso_path, file=sys.stderr)2812 print("Found iso at '%s',\nbut you don't have read permission!\n" % iso_path, file=sys.stderr)
2812 print("Please fix permissions on iso file and try again! Aborting.\n", file=sys.stderr)2813 print("Please fix permissions on iso file and try again! Aborting.\n", file=sys.stderr)
2813 sys.exit(1)2814 sys.exit(1)
2814 return (release_iso, release_num + r)2815 return (release_iso, release_iso.split('-')[1])
28152816
2816 # Fall back to daily/alpha/beta style iso naming2817 # Fall back to daily/alpha/beta style iso naming
2817 release_iso = "%s-%s-%s.iso" % (release, iso_type, arch)2818 release_iso = "%s-%s-%s.iso" % (release, iso_type, arch)
@@ -2900,12 +2901,16 @@ def find_latest_release(release_num, iso_type):
2900 print("Could not reach web server! Please download manually.")2901 print("Could not reach web server! Please download manually.")
2901 sys.exit(1)2902 sys.exit(1)
29022903
2903 for r in [".6", ".5", ".4", ".3", ".2", ".1", ""]:2904 text = re.compile(r'<[^>]+>').sub('', html).split('\n')
2904 attempt = release_num + r2905 matches = []
2905 search = '<a href="%s/">' % attempt2906 for line in text:
2906 if search in html:2907 if line.startswith(' ' + release_num):
2907 print("Found release %s" % attempt)2908 matches.append(line[0:].split('/')[0][1:])
2908 return attempt2909
2910 if len(matches) > 0:
2911 latest_release = sorted(matches)[-1]
2912 print("Found release %s" % latest_release)
2913 return latest_release
29092914
2910 print("Could not find release to download! Please download manually.")2915 print("Could not find release to download! Please download manually.")
2911 sys.exit(1)2916 sys.exit(1)

Subscribers

People subscribed via source and target branches