Example #1
0
def run_bot(patches, working_dir, commit, bot, query):
    results = []

    for series in list.search_subseries(patches, query):
        if not is_pull_request(series) and 'mbox_path' not in series:
            continue

        result = series
        s, steps = try_to_build(series, working_dir, commit, bot)
        result['buildbot'] = {'status': s, 'steps': steps}
        results.append(result)

    results = {
        'patches': results,
        'version': data.VERSION,
        'owner': config.get_buildbot_owner(bot)
    }

    try_rmtree(working_dir)
    util.replace_file(
        config.get_buildbot_json(bot),
        json.dumps(results,
                   indent=2,
                   separators=(',', ': '),
                   encoding='iso-8859-1'))
Example #2
0
def main(_args):
    import data
    import hooks

    hooks.invoke('scan.pre')
    notmuch_dir = config.get_notmuch_dir()
    mail_query = config.get_mail_query()
    search_days = config.get_search_days()
    trees = config.get_trees()

    patches = build_patches(notmuch_dir, search_days, mail_query, trees)
    patches.sort(key=lambda p: p['messages'][0]['full_date'])

    links = config.get_links()

    info = {'version': data.VERSION, 'patches': patches}

    if links:
        info['links'] = links

    replace_file(
        config.get_json_path(),
        json.dumps(info,
                   indent=2,
                   separators=(',', ': '),
                   encoding='iso-8859-1'))

    hooks.invoke('scan.post')

    return 0
Example #3
0
def refresh(args):
    maildir = config.get_notmuch_dir()

    with open('%s/.last' % maildir, 'r') as fp:
        last_msg = int(fp.read())

    mdir = mailbox.Maildir(maildir)
    db = notmuch.Database(maildir, mode=notmuch.Database.MODE.READ_WRITE)

    srv = nntplib.NNTP(config.get_nntp_server())
    _, _, first, last, _ = srv.group(config.get_nntp_group())

    last = int(last)

    clear = False
    for msgno in range(last_msg + 1, last + 1):
        msg = fetch_msg(srv, str(msgno))
        filename = maildir + '/new/' + mdir.add(msg)

        db.begin_atomic()
        try:
            msg, status = db.add_message(filename)
        finally:
            db.end_atomic()

        util.replace_file('%s/.last' % maildir, str(msgno))

        sys.stdout.write('\rFetching message %4d of %4d...    ' % (msgno - last_msg, last - last_msg))
        clear = True
        sys.stdout.flush()

    if clear:
        sys.stdout.write('\n')

    return 0
Example #4
0
def run_bot(patches, working_dir, commit, bot, query):
    results = []

    for series in list.search_subseries(patches, query):
        if not is_pull_request(series) and 'mbox_path' not in series:
            continue

        result = series
        s, steps = try_to_build(series, working_dir, commit, bot)
        result['buildbot'] = { 'status': s, 'steps': steps }
        results.append(result)

    results = { 'patches': results,
                'version': data.VERSION,
                'owner': config.get_buildbot_owner(bot) }

    try_rmtree(working_dir)
    util.replace_file(config.get_buildbot_json(bot),
                      json.dumps(results, indent=2,
                                 separators=(',', ': '),
                                 encoding='iso-8859-1'))
Example #5
0
def refresh(args):
    maildir = config.get_notmuch_dir()

    with open('%s/.last' % maildir, 'r') as fp:
        last_msg = int(fp.read())

    mdir = mailbox.Maildir(maildir)
    db = notmuch.Database(maildir, mode=notmuch.Database.MODE.READ_WRITE)

    srv = nntplib.NNTP(config.get_nntp_server())
    _, _, first, last, _ = srv.group(config.get_nntp_group())

    last = int(last)

    clear = False
    for msgno in range(last_msg + 1, last + 1):
        msg = fetch_msg(srv, str(msgno))
        filename = maildir + '/new/' + mdir.add(msg)

        db.begin_atomic()
        try:
            msg, status = db.add_message(filename)
        finally:
            db.end_atomic()

        util.replace_file('%s/.last' % maildir, str(msgno))

        sys.stdout.write('\rFetching message %4d of %4d...    ' %
                         (msgno - last_msg, last - last_msg))
        clear = True
        sys.stdout.flush()

    if clear:
        sys.stdout.write('\n')

    return 0
Example #6
0
def test():
    ret = util.replace_file('a.txt', r"(?P<p1>.*\.v\s+=\s+').*(?P<p2>';)",
                            r'\g<p1>20180101-1234\g<p2>')
    return str(ret)
Example #7
0
    check_call(git + ['init', '--bare'])
    check_call(git + ['remote', 'add', 'origin', args.url])

    try:
        os.makedirs(maildir.rsplit('/', 1)[0])
    except Exception, e:
        pass

    mdir = mailbox.Maildir(maildir, create=True)
    db = notmuch.Database(maildir, create=True)

    srv = nntplib.NNTP(args.server)
    _, _, first, last, _ = srv.group(args.group)

    first_fetch = max(int(first), int(last) - args.max_msgs)
    util.replace_file('%s/.last' % maildir, str(first_fetch))

    ini = RawConfigParser()
    ini.read([config.config_filename])

    ini.add_section('nntp')
    ini.set('nntp', 'server', args.server)
    ini.set('nntp', 'group', args.group)

    ini.add_section('scan')
    if args.list_tag:
        ini.set('scan', 'list_tag', args.list_tag)
    if args.search_days:
        ini.set('scan', 'search_days', str(args.search_days))
    util.replace_cfg(config.config_filename, ini)
Example #8
0
    check_call(git + ['init', '--bare'])
    check_call(git + ['remote', 'add', 'origin', args.url])

    try:
        os.makedirs(maildir.rsplit('/', 1)[0])
    except Exception, e:
        pass

    mdir = mailbox.Maildir(maildir, create=True)
    db = notmuch.Database(maildir, create=True)

    srv = nntplib.NNTP(args.server)
    _, _, first, last, _ = srv.group(args.group)

    first_fetch = max(int(first), int(last) - args.max_msgs)
    util.replace_file('%s/.last' % maildir, str(first_fetch))

    ini = RawConfigParser()
    ini.read([config.config_filename])

    ini.add_section('nntp')
    ini.set('nntp', 'server', args.server)
    ini.set('nntp', 'group', args.group)

    ini.add_section('scan')
    if args.list_tag:
        ini.set('scan', 'list_tag', args.list_tag)
    if args.search_days:
        ini.set('scan', 'search_days', str(args.search_days))
    util.replace_cfg(config.config_filename, ini)