aae968f2af
From Antelope (2023.1) onwards, primary identifier of any release is release version instead of name[1], we should use release versions in the election tooling also. This migrate the election tooling to use the release version As release repo is not fully migrated to release version yet, we still need to use the release name to fetch the data from release repo. Keeping relaese version as float so that we edit the configuration file with release version a float not with string even string is passed. All the election tools/script/flow has been tested with it and it is working now. [1] https://governance.openstack.org/tc/reference/release-naming.html Change-Id: Ia8a60a9514b1dca5ac97ed8099c34c6c6c7d24e2
90 lines
3.5 KiB
Python
90 lines
3.5 KiB
Python
|
|
import argparse
|
|
import jinja2
|
|
import os
|
|
import sys
|
|
|
|
from openstack_election.cmds import render_statistics as stats
|
|
from openstack_election import config
|
|
from openstack_election import utils
|
|
|
|
conf = config.load_conf()
|
|
|
|
REFERENCE_URL = utils.PROJECTS_URL.replace(
|
|
'raw', 'src') % '/'.join(('tag', conf['tag']))
|
|
LEADERLESS_URL = ('https://governance.openstack.org/resolutions/'
|
|
'20141128-elections-process-for-leaderless-programs.html')
|
|
|
|
time_frame = "%(start_str)s - %(end_str)s" % (conf['timeframe'])
|
|
start_release, _, end_release = conf['timeframe']['name'].partition('-')
|
|
|
|
template_names = ['election_season', 'nominations_kickoff',
|
|
'nominations_last_days', 'end_nominations',
|
|
'voting_kickoff', 'voting_last_days']
|
|
fmt_args = dict(
|
|
email_deadline=conf['timeframe']['email_deadline'],
|
|
end_release=end_release,
|
|
last_release=end_release.lower(),
|
|
leaderless_url=LEADERLESS_URL,
|
|
reference_url=REFERENCE_URL,
|
|
release=conf['release'],
|
|
seats=conf['tc_seats'],
|
|
start_release=start_release,
|
|
time_frame=time_frame,
|
|
)
|
|
|
|
election_type = utils.conf.get('election_type', '').lower()
|
|
if election_type in ['tc', 'combined']:
|
|
fmt_args.update(dict(
|
|
start_nominations=utils.get_event('TC Nominations')['start_str'],
|
|
end_nominations=utils.get_event('TC Nominations')['end_str'],
|
|
campaign_start=utils.get_event('TC Campaigning')['start_str'],
|
|
campaign_end=utils.get_event('TC Campaigning')['end_str'],
|
|
election_start=utils.get_event('TC Election')['start_str'],
|
|
election_end=utils.get_event('TC Election')['end_str'],
|
|
poll_name='OpenStack %s Cycle Technical Committee Election Poll' % (
|
|
conf['release']),
|
|
))
|
|
template_names += ['campaigning_kickoff']
|
|
|
|
# NOTE(tonyb): In the case of a "combined" election we assume that the dates
|
|
# for each "phase" (nominations, campaigning or elections) overlap so updating
|
|
# the end_nominations key here with the PTL date should be safe
|
|
if election_type in ['ptl', 'combined']:
|
|
# NOTE(tonyb): We need an empty item last to ensure the path ends in a
|
|
# tailing '/'
|
|
stats.collect_project_stats(os.path.join(utils.CANDIDATE_PATH,
|
|
conf['release'], ''),
|
|
False, [])
|
|
fmt_args.update(dict(
|
|
end_nominations=utils.get_event('PTL Nominations')['end_str'],
|
|
election_summary_stats=stats.election_summary(),
|
|
leaderless_count=len(stats.without_candidate),
|
|
list_of_leaderless_projects=", ".join(stats.without_candidate),
|
|
election_count=len(stats.need_election),
|
|
election_end=utils.get_event('PTL Election')['end_str'],
|
|
list_of_elections=", ".join(stats.need_election),
|
|
))
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser('Tool to generate form emails')
|
|
parser.add_argument('template', choices=template_names)
|
|
|
|
args = parser.parse_args()
|
|
func_name = ('%(election_type)s_%(template)s' %
|
|
(dict(election_type=conf['election_type'],
|
|
template=args.template)))
|
|
env = jinja2.Environment(
|
|
loader=jinja2.PackageLoader('openstack_election', 'templates'),
|
|
autoescape=jinja2.select_autoescape(['html', 'xml'])
|
|
)
|
|
try:
|
|
template = env.get_template('%s.j2' % func_name)
|
|
print(template.render(fmt_args))
|
|
except jinja2.exceptions.TemplateNotFound:
|
|
print('\nNo %s.j2 template found.\n' % func_name, file=sys.stderr)
|
|
return 1
|
|
|
|
return 0
|