Tim Andersson has proposed merging
~andersson123/qa-jenkins-jobs:catch-regex-exception into qa-jenkins-jobs:master.
Requested reviews:
Canonical Platform QA Team (canonical-platform-qa)
For more details, see:
https://code.launchpad.net/~andersson123/qa-jenkins-jobs/+git/qa-jenkins-jobs/+merge/475630
Catch AttributeError when we don't match a regex and assume something is wonky
with whichever britney
--
Your team Canonical Platform QA Team is requested to review the proposed merge
of ~andersson123/qa-jenkins-jobs:catch-regex-exception into
qa-jenkins-jobs:master.
diff --git a/scripts/archive/check-britney-running-periodically b/scripts/archive/check-britney-running-periodically
index ddca74f..1487b09 100755
--- a/scripts/archive/check-britney-running-periodically
+++ b/scripts/archive/check-britney-running-periodically
@@ -13,7 +13,13 @@ def check_security_britney():
security_britney_url = "http://security-britney.internal/"
content = requests.get(security_britney_url).content.decode("utf-8")
filter_re = re.compile(r'run.log<\/a><\/td><td align="right">(.*?)<')
- match = filter_re.search(content).group(1).rstrip()
+ try:
+ match = filter_re.search(content).group(1).rstrip()
+ except AttributeError as _:
+ print(
+ "Error parsing security-britney latest log - looks like something is wrong with security britney!"
+ )
+ return False
latest_security_britney_run = datetime.datetime.strptime(match, "%Y-%m-%d %H:%M").replace(tzinfo=datetime.timezone.utc)
now = datetime.datetime.now(datetime.timezone.utc)
if (now - latest_security_britney_run) > datetime.timedelta(
@@ -36,7 +42,13 @@ def check_britney():
)
filter_re = re.compile(r"Generated: (.*) \+")
content = requests.get(update_excuses_url).content.decode("utf-8")
- match = filter_re.search(content).group(1)
+ try:
+ match = filter_re.search(content).group(1)
+ except AttributeError as _:
+ print(
+ "Error parsing update_excuses - looks like something is wrong with britney!"
+ )
+ return False
latest_update_excuses = datetime.datetime.strptime(match, "%Y.%m.%d %H:%M:%S").replace(tzinfo=datetime.timezone.utc)
now = datetime.datetime.now(datetime.timezone.utc)
if (now - latest_update_excuses) > datetime.timedelta(hours=MAX_AGE_THRESHOLD):
--
Mailing list: https://launchpad.net/~canonical-ubuntu-qa
Post to : [email protected]
Unsubscribe : https://launchpad.net/~canonical-ubuntu-qa
More help : https://help.launchpad.net/ListHelp