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
1diff --git a/vm-tools/uvt b/vm-tools/uvt
2index 0d5d198..5932cd8 100755
3--- a/vm-tools/uvt
4+++ b/vm-tools/uvt
5@@ -2795,14 +2795,15 @@ def locate_release_iso(release, release_num, arch, iso_type, force):
6 iso_type = "mini"
7
8 # Try and find the latest point release
9- # FIXME: this should list the directory instead of guessing
10- for r in [".7", ".6", ".5", ".4", ".3", ".2", ".1", ""]:
11- if iso_type == "server" and float(release_num) >= 20.04:
12- release_iso = "ubuntu-%s%s-legacy-%s-%s.iso" % (release_num, r, iso_type, arch)
13- else:
14- release_iso = "ubuntu-%s%s-%s-%s.iso" % (release_num, r, iso_type, arch)
15- #print "looking for %s" % release_iso
16- iso_path = os.path.join(uvt_conf['vm_dir_iso'],release_iso)
17+ if iso_type == "server" and float(release_num) >= 20.04:
18+ match_iso = "ubuntu-{}(|.[0-9])-legacy-{}-{}.iso".format(release_num, iso_type, arch)
19+ else:
20+ match_iso = "ubuntu-{}(|.[0-9])-{}-{}.iso".format(release_num, iso_type, arch)
21+
22+ matches = [f for f in os.listdir(uvt_conf['vm_dir_iso']) if re.search(match_iso, f)]
23+ if len(matches) > 0:
24+ release_iso = sorted(matches)[-1]
25+ iso_path = os.path.join(uvt_conf['vm_dir_iso'], release_iso)
26 if os.path.exists(iso_path):
27 # iso image is there, but we don't have read access
28 # this sometimes happens when libvirt mucks with the
29@@ -2811,7 +2812,7 @@ def locate_release_iso(release, release_num, arch, iso_type, force):
30 print("Found iso at '%s',\nbut you don't have read permission!\n" % iso_path, file=sys.stderr)
31 print("Please fix permissions on iso file and try again! Aborting.\n", file=sys.stderr)
32 sys.exit(1)
33- return (release_iso, release_num + r)
34+ return (release_iso, release_iso.split('-')[1])
35
36 # Fall back to daily/alpha/beta style iso naming
37 release_iso = "%s-%s-%s.iso" % (release, iso_type, arch)
38@@ -2900,12 +2901,16 @@ def find_latest_release(release_num, iso_type):
39 print("Could not reach web server! Please download manually.")
40 sys.exit(1)
41
42- for r in [".6", ".5", ".4", ".3", ".2", ".1", ""]:
43- attempt = release_num + r
44- search = '<a href="%s/">' % attempt
45- if search in html:
46- print("Found release %s" % attempt)
47- return attempt
48+ text = re.compile(r'<[^>]+>').sub('', html).split('\n')
49+ matches = []
50+ for line in text:
51+ if line.startswith(' ' + release_num):
52+ matches.append(line[0:].split('/')[0][1:])
53+
54+ if len(matches) > 0:
55+ latest_release = sorted(matches)[-1]
56+ print("Found release %s" % latest_release)
57+ return latest_release
58
59 print("Could not find release to download! Please download manually.")
60 sys.exit(1)

Subscribers

People subscribed via source and target branches