Skip to content

Commit

Permalink
Do not upload to public if unpublished
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon-dxw committed Jul 19, 2024
1 parent b135e14 commit a3e1817
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion utilities/spreadsheet_docx/make_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
DRY_RUN = "--dryrun"
# DRY_RUN = False
DALMATIAN_INFRASTRUCTURE = "caselaw"
ASSETS_BASE = "https://tna-caselaw-assets.s3.amazonaws.com/"
ASSETS_BASE = "https://tna-caselaw-assets.s3.amazonaws.com"
CASELAW_BASE = "https://caselaw.nationalarchives.gov.uk"

SPREADSHEET = "bailii_files.csv"

Expand Down Expand Up @@ -58,6 +59,11 @@ def has_docx_in_s3(self):
response = requests.head(f"{ASSETS_BASE}/{self.target_key()}", timeout=30)
return response.status_code == 200

def is_published(self):
response = requests.head(f"{CASELAW_BASE}/{self.tna_id}", timeout=30)
print(response)
return response.status_code == 200

def copy_command(self, target_bucket):
if target_bucket == UNPUBLISHED_BUCKET:
public_bonus = []
Expand Down Expand Up @@ -147,6 +153,10 @@ def clean_rows(nice_data):
if retcode != 0:
raise RuntimeError

if not doc.is_published():
print(f"Skipping public upload of {doc.target_key()}, not published")
continue

command = doc.copy_command(PUBLISHED_BUCKET)
print(command)
retcode = subprocess.run(command, check=False).returncode
Expand Down

0 comments on commit a3e1817

Please sign in to comment.