2019-11-25 05:01:31 -05:00
|
|
|
#!/usr/bin/python3
|
|
|
|
#
|
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
|
|
# this work for additional information regarding copyright ownership.
|
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
# (the "License"); you may not use this file except in compliance with
|
|
|
|
# the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
2022-06-02 09:07:57 -04:00
|
|
|
from typing import Any, Dict, List
|
2021-07-21 14:46:43 -04:00
|
|
|
|
|
|
|
from click.core import Context
|
2019-11-25 05:01:31 -05:00
|
|
|
|
|
|
|
try:
|
|
|
|
import jinja2
|
|
|
|
except ModuleNotFoundError:
|
|
|
|
exit("Jinja2 is a required dependency for this script")
|
|
|
|
try:
|
|
|
|
import click
|
|
|
|
except ModuleNotFoundError:
|
|
|
|
exit("Click is a required dependency for this script")
|
|
|
|
|
2022-06-02 09:07:57 -04:00
|
|
|
RECEIVER_EMAIL = "dev@superset.apache.org"
|
2019-11-25 05:01:31 -05:00
|
|
|
PROJECT_NAME = "Superset"
|
|
|
|
PROJECT_MODULE = "superset"
|
2020-12-18 07:04:33 -05:00
|
|
|
PROJECT_DESCRIPTION = "Apache Superset is a modern, enterprise-ready business intelligence web application"
|
2019-11-25 05:01:31 -05:00
|
|
|
|
|
|
|
|
|
|
|
def string_comma_to_list(message: str) -> List[str]:
|
|
|
|
if not message:
|
|
|
|
return []
|
2020-02-18 00:14:31 -05:00
|
|
|
return [element.strip() for element in message.split(",")]
|
2019-11-25 05:01:31 -05:00
|
|
|
|
|
|
|
|
2021-07-21 14:46:43 -04:00
|
|
|
def render_template(template_file: str, **kwargs: Any) -> str:
|
2019-11-25 05:01:31 -05:00
|
|
|
"""
|
|
|
|
Simple render template based on named parameters
|
|
|
|
|
|
|
|
:param template_file: The template file location
|
|
|
|
:kwargs: Named parameters to use when rendering the template
|
|
|
|
:return: Rendered template
|
|
|
|
"""
|
|
|
|
template = jinja2.Template(open(template_file).read())
|
|
|
|
return template.render(kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
class BaseParameters(object):
|
|
|
|
def __init__(
|
2022-03-29 13:03:09 -04:00
|
|
|
self,
|
|
|
|
version: str,
|
|
|
|
version_rc: str,
|
2021-07-21 14:46:43 -04:00
|
|
|
) -> None:
|
2019-11-25 05:01:31 -05:00
|
|
|
self.version = version
|
|
|
|
self.version_rc = version_rc
|
2021-07-21 14:46:43 -04:00
|
|
|
self.template_arguments: Dict[str, Any] = {}
|
2019-11-25 05:01:31 -05:00
|
|
|
|
2021-07-21 14:46:43 -04:00
|
|
|
def __repr__(self) -> str:
|
2022-06-02 09:07:57 -04:00
|
|
|
return f"Apache Credentials: {self.version}/{self.version_rc}"
|
2019-11-25 05:01:31 -05:00
|
|
|
|
|
|
|
|
|
|
|
@click.group()
|
|
|
|
@click.pass_context
|
|
|
|
@click.option("--version", envvar="SUPERSET_VERSION")
|
|
|
|
@click.option("--version_rc", envvar="SUPERSET_VERSION_RC")
|
2021-07-21 14:46:43 -04:00
|
|
|
def cli(
|
|
|
|
ctx: Context,
|
|
|
|
version: str,
|
|
|
|
version_rc: str,
|
|
|
|
) -> None:
|
|
|
|
"""Welcome to releasing send email CLI interface!"""
|
2022-06-02 09:07:57 -04:00
|
|
|
base_parameters = BaseParameters(version, version_rc)
|
|
|
|
base_parameters.template_arguments["receiver_email"] = RECEIVER_EMAIL
|
2019-11-25 05:01:31 -05:00
|
|
|
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
|
|
|
|
ctx.obj = base_parameters
|
|
|
|
|
|
|
|
|
|
|
|
@cli.command("vote_pmc")
|
|
|
|
@click.pass_obj
|
2022-06-02 09:07:57 -04:00
|
|
|
def vote_pmc(base_parameters: BaseParameters) -> None:
|
2019-11-25 05:01:31 -05:00
|
|
|
template_file = "email_templates/vote_pmc.j2"
|
|
|
|
message = render_template(template_file, **base_parameters.template_arguments)
|
2022-06-02 09:07:57 -04:00
|
|
|
print(message)
|
2019-11-25 05:01:31 -05:00
|
|
|
|
|
|
|
|
|
|
|
@cli.command("result_pmc")
|
|
|
|
@click.option(
|
|
|
|
"--vote_bindings",
|
|
|
|
default="",
|
|
|
|
type=str,
|
|
|
|
prompt="A List of people with +1 binding vote (ex: Max,Grace,Krist)",
|
|
|
|
)
|
|
|
|
@click.option(
|
|
|
|
"--vote_nonbindings",
|
|
|
|
default="",
|
|
|
|
type=str,
|
|
|
|
prompt="A List of people with +1 non binding vote (ex: Ville)",
|
|
|
|
)
|
|
|
|
@click.option(
|
|
|
|
"--vote_negatives",
|
|
|
|
default="",
|
|
|
|
type=str,
|
|
|
|
prompt="A List of people with -1 vote (ex: John)",
|
|
|
|
)
|
2021-01-19 08:26:28 -05:00
|
|
|
@click.option(
|
|
|
|
"--vote_thread",
|
|
|
|
default="",
|
|
|
|
type=str,
|
|
|
|
prompt="Permalink to the vote thread "
|
|
|
|
"(see https://lists.apache.org/list.html?dev@superset.apache.org)",
|
|
|
|
)
|
2019-11-25 05:01:31 -05:00
|
|
|
@click.pass_obj
|
2019-11-27 10:28:37 -05:00
|
|
|
def result_pmc(
|
2021-07-21 14:46:43 -04:00
|
|
|
base_parameters: BaseParameters,
|
|
|
|
vote_bindings: str,
|
|
|
|
vote_nonbindings: str,
|
|
|
|
vote_negatives: str,
|
|
|
|
vote_thread: str,
|
|
|
|
) -> None:
|
2019-11-25 05:01:31 -05:00
|
|
|
template_file = "email_templates/result_pmc.j2"
|
|
|
|
base_parameters.template_arguments["vote_bindings"] = string_comma_to_list(
|
|
|
|
vote_bindings
|
|
|
|
)
|
|
|
|
base_parameters.template_arguments["vote_nonbindings"] = string_comma_to_list(
|
|
|
|
vote_nonbindings
|
|
|
|
)
|
|
|
|
base_parameters.template_arguments["vote_negatives"] = string_comma_to_list(
|
2019-11-27 10:28:37 -05:00
|
|
|
vote_negatives
|
|
|
|
)
|
2021-01-19 08:26:28 -05:00
|
|
|
base_parameters.template_arguments["vote_thread"] = vote_thread
|
2019-11-25 05:01:31 -05:00
|
|
|
message = render_template(template_file, **base_parameters.template_arguments)
|
2022-06-02 09:07:57 -04:00
|
|
|
print(message)
|
2019-11-25 05:01:31 -05:00
|
|
|
|
|
|
|
|
|
|
|
@cli.command("announce")
|
|
|
|
@click.pass_obj
|
2022-06-02 09:07:57 -04:00
|
|
|
def announce(base_parameters: BaseParameters) -> None:
|
2019-11-25 05:01:31 -05:00
|
|
|
template_file = "email_templates/announce.j2"
|
|
|
|
message = render_template(template_file, **base_parameters.template_arguments)
|
2022-06-02 09:07:57 -04:00
|
|
|
print(message)
|
2019-11-25 05:01:31 -05:00
|
|
|
|
|
|
|
|
|
|
|
cli()
|