Skip to content

Commit

Permalink
Quick patch to fix Angus SSL issues
Browse files Browse the repository at this point in the history
  • Loading branch information
JackGilmore committed Jul 6, 2024
1 parent dc598b5 commit 841ac34
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/alive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
python-version: '3.9'
- name: Set up environment
run: |
pip install pygithub
pip install -r requirements.txt
- name: Run status checker
env:
GITHUB_ACCESS_TOKEN: ${{secrets.ALIVE_GITHUB_TOKEN}}
Expand Down
15 changes: 14 additions & 1 deletion tools/alive.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
import csv
import os
import time
import ssl

GITHUB_REPO = "OpenDataScotland/the_od_bods"


def handle_error(row):
print(f"HANDLING ERROR for {row['Name']}")
return
issue_body = "**Broken URL:** [#{}]({})\n\n".format(
row["Source URL"], row["Source URL"]
)
Expand Down Expand Up @@ -75,8 +78,18 @@ def handle_error(row):
print(f"Polling {url}")

req = Request(url)

ctx = ssl.create_default_context()

# Ignoring SSL checks for Angus because their SSL cert is broken
# TODO: Contact Angus Council to notify them their SSL cert is broken. Remove this once fixed.
if row["Name"] == "Angus Council":
print("Ignoring SSL checks for this domain")
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE

try:
response = urlopen(req)
response = urlopen(req, context=ctx)
print(f"Got status code {response.getcode()} for {req.full_url}")
except HTTPError as e:
print(f"Got status code {e.code} for {req.full_url}")
Expand Down
1 change: 1 addition & 0 deletions tools/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PyGithub==2.3.0

0 comments on commit 841ac34

Please sign in to comment.