示例#1
0
def main(args):
    import json, config
    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()

    def sort_patch(a, b):
        return cmp(b['messages'][0]['full_date'],
                   a['messages'][0]['full_date'])

    patches = build_patches(notmuch_dir, search_days, mail_query, trees)
    patches.sort(sort_patch)

    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
示例#2
0
文件: scan.py 项目: stefanha/patches
def main(args):
    import json, config
    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()

    def sort_patch(a, b):
        return cmp(b['messages'][0]['full_date'], a['messages'][0]['full_date'])

    patches = build_patches(notmuch_dir, search_days, mail_query, trees)
    patches.sort(sort_patch)

    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
示例#3
0
文件: build.py 项目: aliguori/patches
def main(args):
    with open(config.get_json_path(), 'rb') as fp:
        patches = data.parse_json(fp.read())

    working_dir = config.get_working_dir()
    commit = gitcmd.get_sha1(config.get_master_branch())

    bots = args.bots
    if not bots:
        bots = config.get_buildbots()

    for bot in bots:
        q = config.get_buildbot_query(bot)
        run_bot(patches, working_dir, commit, bot, q)
示例#4
0
def main(args):
    with open(config.get_json_path(), 'rb') as fp:
        patches = data.parse_json(fp.read())

    working_dir = config.get_working_dir()
    commit = gitcmd.get_sha1(config.get_master_branch())

    bots = args.bots
    if not bots:
        bots = config.get_buildbots()

    for bot in bots:
        q = config.get_buildbot_query(bot)
        run_bot(patches, working_dir, commit, bot, q)
示例#5
0
文件: list.py 项目: jnsnow/patches
def main(args):
    with open(config.get_json_path(), 'rb') as fp:
        patches = data.parse_json(fp.read())

    if args.format == 'notmuch':
        dump_notmuch_query(patches, args)
    elif args.format == 'oneline':
        dump_oneline_query(patches, args)
    elif args.format == 'full':
        dump_full_query(patches, args)
    elif args.format == 'commits':
        dump_commits(patches, args)
    else:
        raise Exception('unknown format %s' % args.format)

    return 0
示例#6
0
文件: list.py 项目: stefanha/patches
def main(args):
    with open(config.get_json_path(), 'rb') as fp:
        patches = data.parse_json(fp.read())

    if args.format == 'notmuch':
        dump_notmuch_query(patches, args)
    elif args.format == 'oneline':
        dump_oneline_query(patches, args)
    elif args.format == 'full':
        dump_full_query(patches, args)
    elif args.format == 'commits':
        dump_commits(patches, args)
    else:
        raise Exception('unknown format %s' % args.format)

    return 0
示例#7
0
文件: apply.py 项目: aliguori/patches
def main(args):
    with open(config.get_json_path(), 'rb') as fp:
        patches = data.parse_json(fp.read())

    kwds = {}
    if args.git_dir:
        kwds['cwd'] = args.git_dir
    if args.s:
        kwds['signed-off-by'] = True
    if args.interactive:
        kwds['interactive'] = True

    for series in find_subseries(patches, args):
        try:
            s, _ = apply_series(series, **kwds)
            if s:
                return s
        except Exception, e:
            print str(e)
            return 1
示例#8
0
文件: apply.py 项目: jnsnow/patches
def main(args):
    with open(config.get_json_path(), 'rb') as fp:
        patches = data.parse_json(fp.read())

    kwds = {}
    if args.git_dir:
        kwds['cwd'] = args.git_dir
    if args.s:
        kwds['signed-off-by'] = True
    if args.interactive:
        kwds['interactive'] = True

    for series in find_subseries(patches, args):
        try:
            s, _ = apply_series(series, **kwds)
            if s:
                return s
        except Exception, e:
            print str(e)
            return 1
示例#9
0
        mbox_path = series['mbox_path']

        old_hash = mbox.get_hash(mbox_path)

        if 'mbox_hash' in series and series['mbox_hash'] == old_hash:
            continue

        print 'Fetching mbox for %s' % series['messages'][0]['subject']
        base, _ = url.rsplit('/', 1)

        try:
            fp = urlopen(base + '/' + series['mbox_path'])
        except HTTPError, e:
            print 'Skipping mbox %s' % series['mbox_path']
            continue

        try:
            mbox_data = fp.read()
        finally:
            fp.close()

        replace_file(mbox.get_real_path(series['mbox_path']), mbox_data)

    json_data = json.dumps(full_patches,
                           indent=2,
                           separators=(',', ': '),
                           encoding='iso-8859-1')

    replace_file(config.get_json_path(), json_data)
示例#10
0
def main(args):
    import config

    notified_dir = config.get_notified_dir()

    try:
        os.makedirs(notified_dir + '/mid')
    except Exception, e:
        pass

    if args.smtp_server != None:
        config.set('notify', 'smtp_server', args.smtp_server)
    if args.sender != None:
        config.set('notify', 'default_sender', args.sender)

    with open(config.get_json_path(), 'rb') as fp:
        patches = data.parse_json(fp.read())

    nots = []
    if args.labels:
        print args.labels
        def fn(x):
            return (x, config.get_notification(x))
        nots = map(fn, args.labels)
    else:
        nots = config.get_notifications()

    for label, filename in nots:
        with open(filename, 'rb') as fp:
            template = fp.read()
        
示例#11
0
文件: fetch.py 项目: aliguori/patches
            continue

        mbox_path = series['mbox_path']

        old_hash = mbox.get_hash(mbox_path)
        
        if 'mbox_hash' in series and series['mbox_hash'] == old_hash:
            continue

        print 'Fetching mbox for %s' % series['messages'][0]['subject']
        base, _ = url.rsplit('/', 1)

        try:
            fp = urlopen(base + '/' + series['mbox_path'])
        except HTTPError, e:
            print 'Skipping mbox %s' % series['mbox_path']
            continue
            
        try:
            mbox_data = fp.read()
        finally:
            fp.close()

        replace_file(mbox.get_real_path(series['mbox_path']), mbox_data)

    json_data = json.dumps(full_patches, indent=2,
                           separators=(',', ': '),
                           encoding='iso-8859-1')

    replace_file(config.get_json_path(), json_data)
示例#12
0
def main(args):
    import config

    notified_dir = config.get_notified_dir()

    try:
        os.makedirs(notified_dir + '/mid')
    except Exception, e:
        pass

    if args.smtp_server != None:
        config.set('notify', 'smtp_server', args.smtp_server)
    if args.sender != None:
        config.set('notify', 'default_sender', args.sender)

    with open(config.get_json_path(), 'rb') as fp:
        patches = data.parse_json(fp.read())

    nots = []
    if args.labels:
        print args.labels

        def fn(x):
            return (x, config.get_notification(x))

        nots = map(fn, args.labels)
    else:
        nots = config.get_notifications()

    for label, filename in nots:
        with open(filename, 'rb') as fp: