|
1 | 1 | import requests |
2 | | -from requests.exceptions import HTTPError |
3 | 2 | import tempfile |
| 3 | +from requests.exceptions import HTTPError |
| 4 | + |
| 5 | +import os |
4 | 6 | import subprocess |
5 | 7 | from kinto_http import Client, KintoException |
6 | | -import os |
7 | 8 |
|
8 | | -COMMIT_HASH_URL = "https://api.github.com/repos/publicsuffix/list/commits/master" |
| 9 | +COMMIT_HASH_URL = ( |
| 10 | + "https://api.github.com/repos/publicsuffix/list/commits?path=public_suffix_list.dat" |
| 11 | +) |
9 | 12 |
|
10 | 13 | LIST_URL = ( |
11 | 14 | "https://raw.githubusercontent.com/publicsuffix/list/master/public_suffix_list.dat" |
@@ -41,12 +44,7 @@ def inner(*args, **kwargs): |
41 | 44 | def get_latest_hash(): |
42 | 45 | response = requests.get(COMMIT_HASH_URL) |
43 | 46 | response.raise_for_status() |
44 | | - |
45 | | - modified_files = response.json()["files"] |
46 | | - for f in modified_files: |
47 | | - if f["filename"] == "public_suffix_list.dat": |
48 | | - return response.json()["sha"] |
49 | | - return "" |
| 47 | + return response.json()[0]["sha"] |
50 | 48 |
|
51 | 49 |
|
52 | 50 | @handle_request_errors |
@@ -81,9 +79,11 @@ def make_dafsa_and_publish(client, latest_hash): |
81 | 79 | output_binary_path = os.path.join(tmp, output_binary_name) |
82 | 80 |
|
83 | 81 | # Make the DAFSA |
84 | | - subprocess.run( |
| 82 | + run = subprocess.run( |
85 | 83 | ["python3", prepare_tlds_py_path, raw_psl_path, output_binary_path] |
86 | 84 | ) |
| 85 | + if run.returncode != 0: |
| 86 | + return 1 |
87 | 87 |
|
88 | 88 | subprocess.run(["ls", tmp]) |
89 | 89 |
|
@@ -115,7 +115,7 @@ def publish_dafsa(): |
115 | 115 | # print(e) |
116 | 116 |
|
117 | 117 | # if record["data"]["latest-commit-hash"] == latest_hash: |
118 | | - # return 0 |
| 118 | + # return 1 |
119 | 119 | # else: |
120 | 120 | make_dafsa_and_publish(client, latest_hash) |
121 | 121 |
|
|
0 commit comments