From 59c20950945d92e7cb0b5ba0deef6d65064019c9 Mon Sep 17 00:00:00 2001 From: thierrylahaye <65568251+thierrylahaije@users.noreply.github.com> Date: Fri, 23 Aug 2024 03:17:59 +0200 Subject: [PATCH] Update broken_link_checker.py Test update for broken_link_checker. The broken link checker works but does not creates an issue yet. This issue is currently being tackled. --- broken_link_checker.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/broken_link_checker.py b/broken_link_checker.py index 3751cae52..1c21e6914 100644 --- a/broken_link_checker.py +++ b/broken_link_checker.py @@ -169,7 +169,7 @@ def identifyBrokenLinks(uniqueExternalLinks): count = 0 length_uniqueExternalLinks = len(uniqueExternalLinks) - for link in uniqueExternalLinks: + for link in uniqueExternalLinks[:200]: count = count + 1 @@ -223,7 +223,6 @@ def matchBrokenLinks(brokenLinksList,externalLinksListRaw): EndDataFrame = dataframeFinal.merge(dataframeFinal2, left_on='Broken_Link_URL', right_on ='link', how='outer') del EndDataFrame['link'] - def push_issue_git(): #set dt_string with current date/time @@ -255,14 +254,18 @@ def push_issue_git(): issuebody = 'Today, a total of ' + str(len(df3.index)) + ' link errors have been found. The following links have been found containing errors:' + '\n' + tablecomp #defining data to push to git issue - data = {"title": titleissue, "body": issuebody, "assignee": "thierrylahaije"} + data = {"title": titleissue, "body": issuebody} #Post issue message using requests and json - requests.post(url,data=json.dumps(data),headers=headers) - - print('Process succeeded') + response = requests.post(url, data=json.dumps(data), headers=headers) + if response.status_code == 201: + print('Issue created successfully') + else: + print(f'Failed to create issue: {response.status_code} - {response.text}') + else: + print('No broken links found') pass # # Execute Functions