Skip to content

Commit 580d6e0

Browse files
committed
Pick up custom certificate from script path
This ensures that the script can be run from any directory. Fixes c4ad714
1 parent 7348c7a commit 580d6e0

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

update/my_bp.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"""This script downloads the list of states and countries and their
2323
birthplace code from the National Registration Department of Malaysia."""
2424

25+
import os
2526
import re
2627
from collections import defaultdict
2728

@@ -61,19 +62,20 @@ def parse(content):
6162

6263

6364
if __name__ == '__main__':
65+
ca_certificate = os.path.join(os.path.dirname(__file__), 'my_bp.crt')
6466
headers = {
6567
'User-Agent': user_agent,
6668
}
6769
results = defaultdict(lambda: defaultdict(set))
6870
# read the states
69-
response = requests.get(state_list_url, headers=headers, verify='update/my_bp.crt', timeout=30)
71+
response = requests.get(state_list_url, headers=headers, verify=ca_certificate, timeout=30)
7072
response.raise_for_status()
7173
for state, bps in parse(response.content):
7274
for bp in bps:
7375
results[bp]['state'] = state
7476
results[bp]['countries'].add('Malaysia')
7577
# read the countries
76-
response = requests.get(country_list_url, headers=headers, verify='update/my_bp.crt', timeout=30)
78+
response = requests.get(country_list_url, headers=headers, verify=ca_certificate, timeout=30)
7779
response.raise_for_status()
7880
for country, bps in parse(response.content):
7981
for bp in bps:

0 commit comments

Comments
 (0)