Skip to content

Commit

Permalink
Fix the abs file parsing by reading it as binary and decode line by l…
Browse files Browse the repository at this point in the history
…ine as utf-8 as it only cares Date line. No sending of alert mail (as the sub2gcp takes it over)
  • Loading branch information
ntai-arxiv committed Sep 23, 2024
1 parent cb5f15d commit f0fad6c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions script/sync_prod_to_gcp/submissions_to_gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,18 @@ def update_metadata(self):
abs_path = self.source_path(".abs")
dates = []
try:
with open(abs_path, "r", encoding="utf-8") as abs_fd:
for line in abs_fd.readlines():
sline = line.strip()
if sline == "":
break
if sline.startswith("Date"):
dates.append(sline)
with open(abs_path, "rb") as abs_fd:
abstract = abs_fd.read()
for line in abstract.split(b'\n'):
try:
sline = line.decode('utf-8')
if sline == "":
break
if sline.startswith("Date"):
dates.append(sline)
except UnicodeDecodeError:
# Don't care the non- uft-8 lines as date line is a generated text.
pass

except FileNotFoundError as exc:
msg = f"abs file {abs_path} does not exist"
Expand Down
2 changes: 1 addition & 1 deletion script/sync_prod_to_gcp/webnode_pdf_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def ping_callback(message: Message) -> None:
help_needed = os.environ.get("TEX_COMPILATION_RECIPIENT", "help@arxiv.org")
subject = f"TeX compilation for {paper_id}v{version} failed"
mail_body = f"Hello EUST,\nTex compilation for {paper_id}v{version} has failed. Please resolve the issue.\n\nThis message is generated by a bot on arxiv-sync.serverfarm.cornell.edu.\n"
cmd = ["/usr/bin/mail", "-r", "developers@arxiv.org", "-s", subject, help_needed]
cmd = ["echo", "/usr/bin/mail", "-r", "developers@arxiv.org", "-s", subject, help_needed]
mail = subprocess.Popen(cmd,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try:
Expand Down

0 comments on commit f0fad6c

Please sign in to comment.