|
27 | 27 | page = urllib.request.urlopen(download_url) |
28 | 28 | soup = BeautifulSoup(page, 'html.parser') |
29 | 29 | full_text = soup.get_text() |
30 | | -split = full_text.split("generated") |
| 30 | +split = full_text.split("Daily snapshot from") |
31 | 31 |
|
32 | 32 | today_date = datetime.date.today() |
33 | 33 |
|
34 | 34 | exit_code = 0 |
35 | 35 |
|
36 | 36 | # Process each instance of the keyword on the page, because we can have multiple QA and master versions |
37 | 37 | for substring in split: |
| 38 | + substring_pieces = substring.split() |
| 39 | + if substring_pieces[0] == 'Downloads': |
| 40 | + continue |
| 41 | + |
38 | 42 | # Take only the date, not the entire page following it |
39 | | - generated_date = substring.split()[0] |
40 | | - # Strip off the trailing comma |
41 | | - if generated_date.endswith(','): |
42 | | - generated_date = generated_date[:-1] |
43 | | - if generated_date != 'phpMyAdmin': |
44 | | - converted_date = datetime.datetime.strptime(generated_date, '%Y-%m-%d').date() |
45 | | - difference = today_date - converted_date |
46 | | - # We give an extra day as a buffer to account for time zones |
47 | | - if difference > datetime.timedelta(days=1): |
48 | | - print("Problem found") |
49 | | - print(("Current date: " + today_date.strftime('%Y-%m-%d'))) |
50 | | - print(("Snapshot date: " + generated_date)) |
51 | | - exit_code = 1 |
52 | | - else: |
53 | | - print("Everything is groovy") |
| 43 | + generated_date = substring_pieces[0] + ' ' + substring_pieces[1] + ' ' + substring_pieces[2][:-1] |
| 44 | + converted_date = datetime.datetime.strptime(generated_date, '%B %d, %Y').date() |
| 45 | + difference = today_date - converted_date |
| 46 | + # We give an extra day as a buffer to account for time zones |
| 47 | + if difference > datetime.timedelta(days=1): |
| 48 | + print("Problem found") |
| 49 | + print(("Current date: " + today_date.strftime('%Y-%m-%d'))) |
| 50 | + print(("Snapshot date: " + generated_date)) |
| 51 | + exit_code = 1 |
| 52 | + else: |
| 53 | + print("Everything is groovy") |
54 | 54 |
|
55 | 55 | sys.exit(exit_code) |
0 commit comments