Skip to content

Commit

Permalink
Pick up custom certificate from script path
Browse files Browse the repository at this point in the history
This ensures that the script can be run from any directory.

Fixes c4ad714
  • Loading branch information
arthurdejong committed Nov 13, 2022
1 parent 7348c7a commit 580d6e0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions update/my_bp.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"""This script downloads the list of states and countries and their
birthplace code from the National Registration Department of Malaysia."""

import os
import re
from collections import defaultdict

Expand Down Expand Up @@ -61,19 +62,20 @@ def parse(content):


if __name__ == '__main__':
ca_certificate = os.path.join(os.path.dirname(__file__), 'my_bp.crt')
headers = {
'User-Agent': user_agent,
}
results = defaultdict(lambda: defaultdict(set))
# read the states
response = requests.get(state_list_url, headers=headers, verify='update/my_bp.crt', timeout=30)
response = requests.get(state_list_url, headers=headers, verify=ca_certificate, timeout=30)
response.raise_for_status()
for state, bps in parse(response.content):
for bp in bps:
results[bp]['state'] = state
results[bp]['countries'].add('Malaysia')
# read the countries
response = requests.get(country_list_url, headers=headers, verify='update/my_bp.crt', timeout=30)
response = requests.get(country_list_url, headers=headers, verify=ca_certificate, timeout=30)
response.raise_for_status()
for country, bps in parse(response.content):
for bp in bps:
Expand Down

0 comments on commit 580d6e0

Please sign in to comment.