Skip to content

Commit 64ab6a9

Browse files
committed
latest_timestamps.py: show url and status on failure
eg to identify which pulp_path is incorrect
1 parent 938fa85 commit 64ab6a9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

ansible/library/latest_timestamps.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,21 @@ def run_module(): # pylint: disable=missing-function-docstring
6161
timestamps = dict(module.params["repos_dict"])
6262
for repo in timestamps:
6363
for version in timestamps[repo]:
64-
65-
html_txt = requests.get(
66-
url=module.params["content_url"]
64+
url = (
65+
module.params["content_url"]
6766
+ "/"
6867
+ timestamps[repo][version]["pulp_path"]
69-
).text
68+
)
69+
html = requests.get(url=url)
70+
if not html.ok:
71+
module.fail_json(
72+
msg=(
73+
f"Couldn't retrieve timestamps for {repo}[{version}]"
74+
f"url {url}: {html.status_code} {html.text}"
75+
)
76+
)
7077
timestamp_link_list = (
71-
BeautifulSoup(html_txt, features="html.parser")
78+
BeautifulSoup(html.text, features="html.parser")
7279
.body.find("pre")
7380
.find_all()
7481
) # getting raw list of timestamps from html

0 commit comments

Comments
 (0)