Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[arxivce-2619] Use alternate "sendmail" to talk to non-local MTA - mail.arxiv.org #737

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions script/sync_prod_to_gcp/submissions_to_gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ class SubmissionFilesState:
publish_type: str
version: str # from the publish event
log_extra: dict
submission_source: typing.Optional[dict]
submission_source: typing.Optional[str]
published_versions: typing.List[dict]

_top_levels: dict
Expand Down Expand Up @@ -770,7 +770,7 @@ def submission_message_to_file_state(data: dict, log_extra: dict, ask_webnode: b
source_mtime=file_state.get_submission_mtime())

except sync_published_to_gcp.WebnodeException as exc:
raise MissingGeneratedFile("Failed to generate %s", pdf_path) from exc
raise MissingGeneratedFile("Failed to generate %s" % pdf_path) from exc

except ReadTimeout as exc:
# This happens when failed to talk to webnode
Expand Down Expand Up @@ -810,7 +810,7 @@ def submission_message_to_file_state(data: dict, log_extra: dict, ask_webnode: b
file_state.register_files('html-files', html_files)

except sync_published_to_gcp.WebnodeException as _exc:
raise MissingGeneratedFile("Failed to generate %s", html_path) from _exc
raise MissingGeneratedFile("Failed to generate %s" % html_path) from _exc

except Exception as _exc:
logger.warning("ensure_html: %s", file_state.vxid.ids, extra=log_extra,
Expand Down Expand Up @@ -955,10 +955,22 @@ def submission_callback(message: Message) -> None:
help_needed = os.environ.get("TEX_COMPILATION_RECIPIENT", "[email protected]")
subject = f"Uploading of {paper_id}v{version} failed"
mail_body = f"Hello EUST,\nSubmission uploading 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", "[email protected]", "-s", subject, help_needed]
SENDER = os.environ.get("SENDER", "[email protected]")
SMTP_SERVER = os.environ.get("SMTP_SERVER", "mail.arxiv.org")
SMTP_PORT = os.environ.get("SMTP_PORT", "25")
cmd = ["/usr/local/bin/arxiv-mail",
"-t", help_needed,
"-f", SENDER,
"-m", SMTP_SERVER,
"-p", SMTP_PORT,
"-s", subject,
]
# using sendmail
# cmd = ["/usr/bin/mail", "-r", "[email protected]", "-s", subject, help_needed]

mail = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try:
mail.communicate(mail_body, timeout=60)
mail.communicate(mail_body.encode('utf-8'), timeout=60)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mail_body above is ascii - does the .encode call make any difference? Or is it future-proofing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The body text is no doubt 7-bit ascii. dosen't hurt to use utf-8. So "future proof" if you like.

if mail.returncode == 0:
# Once the email message is sent, done here.
message.ack()
Expand Down Expand Up @@ -994,7 +1006,7 @@ def submission_callback(message: Message) -> None:



def sync_to_gcp(state: SubmissionFilesState, log_extra: dict) -> bool:
def sync_to_gcp(state: SubmissionFilesState, log_extra: dict) -> None:
"""
From the submission file state, copy the ones that should bu uploaded.

Expand Down
Loading