Skip to content

Commit 43d5fb3

Browse files
committed
Fix monitoring/check_phpmyadmin_daily_snapshots.py
- Related to #186 Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.com.br>
1 parent 13ac758 commit 43d5fb3

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

monitoring/check_phpmyadmin_daily_snapshots.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,29 @@
2727
page = urllib.request.urlopen(download_url)
2828
soup = BeautifulSoup(page, 'html.parser')
2929
full_text = soup.get_text()
30-
split = full_text.split("generated")
30+
split = full_text.split("Daily snapshot from")
3131

3232
today_date = datetime.date.today()
3333

3434
exit_code = 0
3535

3636
# Process each instance of the keyword on the page, because we can have multiple QA and master versions
3737
for substring in split:
38+
substring_pieces = substring.split()
39+
if substring_pieces[0] == 'Downloads':
40+
continue
41+
3842
# 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")
5454

5555
sys.exit(exit_code)

0 commit comments

Comments
 (0)