Example #1
0
def main():
    desc = 'Generate or update an election archive for site rendering'
    parser = argparse.ArgumentParser(description=desc)
    parser.add_argument('-v', '--verbose', action="count", default=0,
                        help='Increase program verbosity')
    parser.add_argument('-r', '--release', default=utils.conf['release'],
                        help='Which nominations to look at')
    parser.add_argument('-b', '--basedir',
                        default=os.getcwd(),
                        help='Path to git clone of openstack/election')
    parser.add_argument('round', choices=('ptl', 'tc'))

    args = parser.parse_args()

    args.outputdir = os.path.join(args.basedir, 'doc', 'source', args.release)
    args.outputdir = os.path.expanduser(args.outputdir)

    if not os.path.isdir(args.outputdir):
        os.mkdir(args.outputdir, 0o755)

    db_file = os.path.join(args.outputdir, "%s.yaml" % args.round)

    if os.path.isfile(db_file):
        print("[+] Reloading candidate list %s" % db_file)
        db = yaml.safe_load(open(db_file))
    else:
        db = utils.build_candidates_list(args.release)

    if process(db, args.round):
        open(db_file, "w").write(yaml.safe_dump(db, default_flow_style=False))
        print("[W] Proceed to manual update of %s" % db_file)
Example #2
0
def main():
    desc = 'Generate or update an election archive for site rendering'
    parser = argparse.ArgumentParser(description=desc)
    parser.add_argument('-v', '--verbose', action="count", default=0,
                        help='Increase program verbosity')
    parser.add_argument('-r', '--release', default=utils.conf['release'],
                        help='Which nominations to look at')
    parser.add_argument('-b', '--basedir',
                        default=os.getcwd(),
                        help='Path to git clone of openstack/election')
    parser.add_argument('round', choices=('ptl', 'tc'))

    args = parser.parse_args()

    args.outputdir = os.path.join(args.basedir, 'doc', 'source',
                                  'results', args.release)
    args.outputdir = os.path.expanduser(args.outputdir)

    if not os.path.isdir(args.outputdir):
        os.mkdir(args.outputdir, 0o755)

    db_file = os.path.join(args.outputdir, "%s.yaml" % args.round)

    if os.path.isfile(db_file):
        print("[+] Reloading candidate list %s" % db_file)
        db = yaml.safe_load(open(db_file))
    else:
        db = utils.build_candidates_list(args.release)

    if process(db, args.round):
        open(db_file, "w").write(yaml.safe_dump(db, default_flow_style=False))
        print("[W] Proceed to manual update of %s" % db_file)
Example #3
0
def build_lists(app):
    # Current candidates
    candidates_list = utils.build_candidates_list()
    render_list("ptl", candidates_list)
    render_list("tc", candidates_list)

    # Archived elections
    previous_toc = [".. toctree::", "    :maxdepth: 1", "    :titlesonly:", ""]
    for previous in utils.PAST_ELECTIONS:
        if build_archive(previous, "ptl"):
            previous_toc.append("    %s/ptl.rst" % previous)
        if build_archive(previous, "tc"):
            previous_toc.append("    %s/tc.rst" % previous)
    toc = os.path.join(".", "doc", "source", "archive_toc.rst")
    open(toc, "w").write("\n".join(previous_toc))
Example #4
0
    def test_valid_candidate(self, mock_candidates_list, mock_lookup_member):

        mock_candidates_list.return_value = [
            'candidates/fake/SomeProject/[email protected]'
        ]
        member = dict(irc='ircnick',
                      first_name='Avery',
                      last_name='Developer')
        mock_lookup_member.return_value = dict(data=[member])

        expected = dict(candidates=mock.ANY, election='fake',
                        leaderless=mock.ANY,
                        projects=['SomeProject'])
        observed = utils.build_candidates_list('fake')
        self.assertEqual(expected, observed)
Example #5
0
def build_lists(app):
    # Current candidates
    candidates_list = utils.build_candidates_list()
    if not utils.is_tc_election():
        render_list("ptl", candidates_list)
    else:
        render_list("tc", candidates_list)

    # Archived elections
    previous_toc = [".. toctree::", "    :maxdepth: 1", "    :titlesonly:", ""]
    archived_dir = os.path.join(".", "doc", "source", "results")
    for previous in sorted(os.listdir(archived_dir), reverse=True):
        if build_archive(previous, "ptl"):
            previous_toc.append("    results/%s/ptl.rst" % previous)
        if build_archive(previous, "tc"):
            previous_toc.append("    results/%s/tc.rst" % previous)
    toc = os.path.join(".", "doc", "source", "archive_toc.rst")
    open(toc, "w").write("\n".join(previous_toc))
Example #6
0
def build_lists(app):
    if utils.election_is_running():
        # Current candidates
        candidates_list = utils.build_candidates_list()
        election_type = utils.conf.get('election_type', '').lower()
        render_list(election_type, candidates_list)

    # Archived elections
    previous_toc = [".. toctree::", "    :maxdepth: 1", "    :titlesonly:", ""]
    archived_dir = os.path.join(".", "doc", "source", "results")
    for previous in sorted(os.listdir(archived_dir), reverse=True):
        if build_archive(previous, "ptl"):
            previous_toc.append("    results/%s/ptl.rst" % previous)
        if build_archive(previous, "tc"):
            previous_toc.append("    results/%s/tc.rst" % previous)
    toc = os.path.join(".", "doc", "source", "archive_toc.rst")
    with open(toc, "w") as toc_fd:
        LOG.info('writing TOC to %s', toc)
        toc_fd.write("\n".join(previous_toc))
Example #7
0
def build_lists(app):
    # Current candidates
    candidates_list = utils.build_candidates_list()
    render_list("ptl", candidates_list)
    render_list("tc", candidates_list)

    # Archived elections
    previous_toc = [
        ".. toctree::",
        "    :maxdepth: 1",
        "    :titlesonly:",
        ""
    ]
    for previous in utils.conf['past_elections']:
        if build_archive(previous, "ptl"):
            previous_toc.append("    %s/ptl.rst" % previous)
        if build_archive(previous, "tc"):
            previous_toc.append("    %s/tc.rst" % previous)
    toc = os.path.join(".", "doc", "source", "archive_toc.rst")
    open(toc, "w").write("\n".join(previous_toc))
Example #8
0
def load_candidates():
    print('Loading Candidates')
    candidates_list = utils.build_candidates_list()
    print('Done')
    return candidates_list