diff options
author | Deepti B. Kalakeri <deepti.kalakeri@linaro.org> | 2012-08-27 13:03:19 +0530 |
---|---|---|
committer | Deepti B. Kalakeri <deepti.kalakeri@linaro.org> | 2012-08-27 13:03:19 +0530 |
commit | 25b09159818f7c48b42ccddf25d0bfcff92304aa (patch) | |
tree | 133983cec4f638da912c92ecf035c0d67db5294a /find_latest.py | |
parent | 7f2d65be2b641dff1701a33eadb664c35489a45d (diff) |
Modifying pattern matching for finding latest hwpack tested to align with django based snapshots
Diffstat (limited to 'find_latest.py')
-rw-r--r-- | find_latest.py | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/find_latest.py b/find_latest.py index b0d09be..08c552a 100644 --- a/find_latest.py +++ b/find_latest.py @@ -92,36 +92,30 @@ def find_latest_hwpack(hwpack): filename = find_latest(url) return filename -def find_ci_builds(data): - found = [] - pattern = re.compile('(?P<hp_name>[\w\-\.]+\.tar\.gz)</a></td><td align="right">'\ - '(?P<hp_timestamp>\d{2}-\w{3}-\d{4}\s\d{2}:\d{2})\s\s</td>') +def find_ci_builds(data, latest_hwpack): + + found = False for line in data.splitlines(): - search = pattern.search(line) - if search: - hp_timestamp = datetime.strptime(search.group('hp_timestamp'), - '%d-%b-%Y %H:%M') - found.append([search.group('hp_name'), hp_timestamp]) + if latest_hwpack in line: + found = True + break return found -def find_ci_latest(url): +def find_ci_latest(url, latest_hwpack): """Find the latest image at the specified url :param url: The base url to search :param extra: The extra path needed to complete the url """ + filename = None fetcher = LicenseProtectedFileFetcher() builddates = fetcher.get(url) - dates = find_ci_builds(builddates) - dates = sorted(dates, key=lambda x: x[1]) + found = find_ci_builds(builddates, latest_hwpack) try: - while dates: - lastdate = dates.pop() - filename = os.path.join(url, lastdate[0]) - if filename: - raise StopIteration() - except StopIteration: + if found: + filename = os.path.join(url, latest_hwpack) + except Exception: pass fetcher.close() return filename |