villebro commented on code in PR #20231:
URL: https://github.com/apache/superset/pull/20231#discussion_r887767714
##########
RELEASING/generate_email.py:
##########
@@ -75,122 +52,48 @@ def render_template(template_file: str, **kwargs: Any) ->
str:
return template.render(kwargs)
-def inter_send_email(
- username: str, password: str, sender_email: str, receiver_email: str,
message: str
-) -> None:
- print("--------------------------")
- print("SMTP Message")
- print("--------------------------")
- print(message)
- print("--------------------------")
- confirm = input("Is the Email message ok? (yes/no): ")
- if confirm not in ("Yes", "yes", "y"):
- exit("Exit by user request")
-
- try:
- send_email(
- SMTP_SERVER,
- SMTP_PORT,
- username,
- password,
- sender_email,
- receiver_email,
- message,
- )
- print("Email sent successfully")
- except smtplib.SMTPAuthenticationError:
- exit("SMTP User authentication error, Email not sent!")
- except Exception as e:
- exit(f"SMTP exception {e}")
-
-
class BaseParameters(object):
def __init__(
self,
- email: str,
- username: str,
- password: str,
version: str,
version_rc: str,
) -> None:
- self.email = email
- self.username = username
- self.password = password
self.version = version
self.version_rc = version_rc
self.template_arguments: Dict[str, Any] = {}
def __repr__(self) -> str:
- return f"Apache Credentials:
{self.email}/{self.username}/{self.version}/{self.version_rc}"
+ return f"Apache Credentials: {self.version}/{self.version_rc}"
@click.group()
@click.pass_context
[email protected](
- "--apache_email",
- prompt="Apache Email",
- help="Your Apache email this will be used for SMTP From",
-)
[email protected](
- "--apache_username", prompt="Apache username", help="Your LDAP Apache
username"
-)
[email protected](
- "--apache_password",
- prompt="Apache password",
- hide_input=True,
- help="Your LDAP Apache password",
-)
@click.option("--version", envvar="SUPERSET_VERSION")
@click.option("--version_rc", envvar="SUPERSET_VERSION_RC")
def cli(
ctx: Context,
- apache_email: str,
- apache_username: str,
- apache_password: str,
version: str,
version_rc: str,
) -> None:
"""Welcome to releasing send email CLI interface!"""
- base_parameters = BaseParameters(
- apache_email, apache_username, apache_password, version, version_rc
- )
+ base_parameters = BaseParameters(version, version_rc)
base_parameters.template_arguments["project_name"] = PROJECT_NAME
base_parameters.template_arguments["project_module"] = PROJECT_MODULE
base_parameters.template_arguments["project_description"] =
PROJECT_DESCRIPTION
base_parameters.template_arguments["version"] = base_parameters.version
base_parameters.template_arguments["version_rc"] =
base_parameters.version_rc
- base_parameters.template_arguments["sender_email"] = base_parameters.email
ctx.obj = base_parameters
@cli.command("vote_pmc")
[email protected](
- "--receiver_email",
- default="[email protected]",
- type=str,
- prompt="The receiver email (To:)",
-)
@click.pass_obj
-def vote_pmc(base_parameters: BaseParameters, receiver_email: str) -> None:
+def vote_pmc(base_parameters: BaseParameters) -> None:
template_file = "email_templates/vote_pmc.j2"
- base_parameters.template_arguments["receiver_email"] = receiver_email
message = render_template(template_file,
**base_parameters.template_arguments)
- inter_send_email(
- base_parameters.username,
- base_parameters.password,
- base_parameters.template_arguments["sender_email"],
- base_parameters.template_arguments["receiver_email"],
- message,
- )
+ print(message)
Review Comment:
For convenience, it could be a good idea to print the receiver email here
(`[email protected]`), as it's not expected to change in the foreseeable
future. But I wouldn't ask for it, just print the one that was previously the
default for `receiver_email`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]