Пример #1
0
def update_projects(projects_fname, candidates_list, projects):
    results = utils.get_ptl_results()
    project_count = 0
    with open(projects_fname, 'w') as fh:
        skip = 0
        for line in projects:
            if skip > 0:
                skip -= 1
                continue
            # Projects are detectable as they have no whitespace in column 0
            match = re.match('^([^ \t][^:]+?):$', line)
            if match:
                project_count += 1
                p = utils.name2dir(match.group(1))
                try:
                    candidates = candidates_list['candidates'][p]
                except KeyError:
                    # Add placeholder for required TC appointment in cases
                    # where there is no candidate
                    candidates = [{
                        'fullname': 'APPOINTMENT NEEDED',
                        'ircname': '',
                        'email': '*****@*****.**',
                    }]
                    print('TC to appoint PTL for %s' % (p))
                nr_candidates = len(candidates)
                # Remove non-elected candidates if the election is closed
                # TODO(fungi): rework this entire function to just use the
                # election results file if we have one and not iterate over
                # the candidates tree
                if nr_candidates > 1:
                    for c1 in results['candidates'].get(p, []):
                        if not c1['elected']:
                            for c2 in list(candidates):
                                if c1['email'] == c2['email']:
                                    candidates.remove(c2)
                nr_candidates = len(candidates)
                # Only update the PTL if there is a single candidate
                if nr_candidates == 1:
                    # Replace empty IRC nick strings with something useful
                    if not candidates[0]['ircname']:
                        candidates[0]['ircname'] = 'No nick supplied'
                    line += (
                        ('  ptl:\n' + '    name: %(fullname)s\n' +
                         '    irc: %(ircname)s\n' + '    email: %(email)s\n') %
                        (candidates[0]))
                    # This is a little fragile but the std. form is that the 4
                    # lines after the project name are the PTL details.  We've
                    # just written out new record so skip the next 4 lines in
                    # the projects file.
                    skip = 4
                else:
                    print('Skipping %s election in progress %d candidates' %
                          (p, nr_candidates))
            fh.write(line)

    print('Processed %d projects' % (project_count))
def main():
    if not os.path.isdir("candidates"):
        print("candidates directory not found")
        exit(1)

    base_dir = "candidates/%s" % utils.conf['release']
    projects = utils.get_projects()
    project_list = list(projects.keys())
    project_list.sort()
    for project in project_list + ["TC"]:
        dpath = "%s/%s" % (base_dir, utils.name2dir(project))
        if not os.path.exists(dpath):
            os.makedirs(dpath)
            open("%s/.placeholder" % dpath, "w").close()
            print("[+] Created %s" % (dpath))
Пример #3
0
def main():
    if not os.path.isdir("candidates"):
        print("candidates directory not found")
        exit(1)

    base_dir = "candidates/%s" % utils.conf['release']
    if os.path.exists(base_dir):
        print("%s: directory already exists" % base_dir)
        exit(1)

    projects = utils.get_projects()
    project_list = projects.keys()
    project_list.sort()
    for project in project_list + ["TC"]:
        dpath = "%s/%s" % (base_dir, utils.name2dir(project))
        os.makedirs(dpath)
        open("%s/.placeholder" % dpath, "w").close()
        print("[+] Created %s" % (dpath))
Пример #4
0
def update_projects(projects_fname, candidates_list, projects):
    project_count = 0
    with open(projects_fname, 'w') as fh:
        skip = 0
        for line in projects:
            if skip > 0:
                skip -= 1
                continue
            line = line.decode('utf-8')
            # Projects are detectable as they have no whitespace in column 0
            match = re.match('^([^ \t][^:]+?):$', line)
            if match:
                project_count += 1
                p = utils.name2dir(match.group(1))
                candidates = candidates_list['candidates'][p]
                nr_candidates = len(candidates)
                # Only update the PTL if there is a sinble candidate
                if nr_candidates == 1:
                    line += (
                        ('  ptl:\n' + '    name: %(fullname)s\n' +
                         '    irc: %(ircname)s\n' + '    email: %(email)s\n') %
                        (candidates[0]))
                    # This is a little fragile but the std. form is that the 4
                    # lines after the project name are the PTL details.  We've
                    # just written out new record so skip the next 4 lines in
                    # the projects file.
                    skip = 4
                # Projects with no candidates need to be appointed by the TC
                elif nr_candidates == 0:
                    print('Skipping %s TC to appiont' % (p))
                else:
                    print('Skipping %s election in progress %d candidates' %
                          (p, nr_candidates))
            fh.write(line.encode('utf-8'))

    print('Processed %d projects' % (project_count))
Пример #5
0
import argparse
import os

from openstack_election import utils

parser = argparse.ArgumentParser()
parser.add_argument('name', help='The release cycle name')
parser.add_argument("--root", help='Election directory', default='.')
options = parser.parse_args()

os.chdir(options.root)
if not os.path.isdir("candidates"):
    print("candidates directory not found")
    exit(1)

if os.path.exists("candidates/%s" % options.name):
    print("candidates/%s: directory already exists" % (options.name))
    exit(1)

projects = utils.get_projects()
project_list = projects.keys()
project_list.sort()
for project in project_list + ["TC"]:
    dpath = "candidates/%s/%s" % (options.name, utils.name2dir(project))
    os.makedirs(dpath)
    open("%s/.placeholder" % dpath, "w").close()
    print("[+] Created %s" % (dpath))

print("Done. Now please manually update events.yaml and "
      "doc/source/index.rst substitutions")
Пример #6
0
 def test_name2dir(self):
     name = "nova"
     dirname = "Nova"
     self.assertEqual(dirname, utils.name2dir(name))