示例#1
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)
示例#2
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)
示例#3
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
示例#4
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
示例#5
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
示例#6
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
示例#7
0
def get_annotations():
    filename = data.filename
    print "Parsing JSON data..."
    raw_data = data.parse_json(filename)
    num_accounts = len(raw_data)
    print "Reading DataFrame..."
    df = pd.read_csv('../data/alldata.csv', sep='\t', encoding='utf-8')
    size = len(df)
    # indices for dataframe
    print "Preparing Label DataFrame..."
    index = [x for x in range(size)]
    columns = ['likes', 'username', 'display_src', 'hour', 'day']
    tagdf = pd.DataFrame(index=index, columns=columns)
    x = 0

    tagdf['likes'] = df['likes']
    tagdf['username'] = df['username']
    tagdf['display_src'] = df['display_src']
    tagdf['hour'] = pd.to_datetime(df['date'], unit='s').dt.hour
    tagdf['day'] = pd.to_datetime(df['date'], unit='s').dt.weekday
    print "Starting Iteration"
    for i in range(num_accounts):
        posts = raw_data[i]['posts']
        for j in range(len(posts)):
            # annotations
            annotations = posts[j]['annotations']
            # 1416 labels with score: 0 - 1
            if 'labelAnnotations' in annotations:
                # Sets each label as a new feature with its  value the label's score
                for item in annotations['labelAnnotations']:
                    description = item['description'].encode('utf-8').replace(
                        ' ', '_').replace("'", "")
                    score = np.float(item['score'])
                    # This also sets new columns to NaN
                    tagdf.set_value(x, description, score)
#            if 'faceAnnotations' in annotations:
#                pass
# extracts texts from image... do we need this?
#            if 'textAnnotations' in annotations:
#                pass
#            if 'webDetection' in annotations:
#                pass
#            if 'imagePropertiesAnnotation' in annotations:
#                pass
#            if 'fullTextAnnotation' in annotations:
#                pass
#            if 'cropHintsAnnotation' in annotations:
#                pass
# This format is simple: 4 features, rating
#            if 'safeSearchAnnotation' in annotations:
#                violence = str(annotations['safeSearchAnnotation']['violence'])
#                print(likes, violence)
# VERY_UNLIKELY, UNLIKELY
# medical
# spoof
# violence
# adult
#                pass
            print x
            x += 1
    return tagdf
示例#8
0
    if not url:
        raise Exception(
            'URL not specified in config file and missing on command line')

    try:
        os.makedirs(config.get_mbox_path())
    except Exception, e:
        pass

    fp = urlopen(url)
    try:
        json_data = fp.read()
    finally:
        fp.close()

    full_patches = data.parse_json(json_data, full=True)
    patches = full_patches['patches']

    print 'Fetched info on %d patch series' % len(patches)
    if 'links' in full_patches:
        print 'Fetching links...'

        mids = {}
        for name in full_patches['links']:
            url = full_patches['links'][name]

            fp = urlopen(url)
            try:
                link_data = fp.read()
            finally:
                fp.close()
示例#9
0
    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()
        
        notify(args, patches, notified_dir, 'label:%s' % label, template)
示例#10
0
文件: stats.py 项目: jnsnow/patches
#
# This work is licensed under the terms of the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.
#

import data, sys


def is_reviewed(patch):
    for tag in patch['tags']:
        if tag.startswith('Reviewed-by: '):
            return True
    return False


patches = data.parse_json(sys.stdin.read())

total_series = 0
total_patches = 0
total_reviews = 0
total_obsolete = 0
total_broken = 0
total_committed = 0
total_not_builds = 0
total_not_applies = 0
total_unreviewed = 0

for series in patches:
    total_series += 1

    is_broken = "broken" in series and series["broken"]
示例#11
0
文件: fetch.py 项目: aliguori/patches
    if not url:
        raise Exception('URL not specified in config file and missing on command line')

    try:
        os.makedirs(config.get_mbox_path())
    except Exception, e:
        pass

    fp = urlopen(url)
    try:
        json_data = fp.read()
    finally:
        fp.close()

    full_patches = data.parse_json(json_data, full=True)
    patches = full_patches['patches']

    print 'Fetched info on %d patch series' % len(patches)
    if 'links' in full_patches:
        print 'Fetching links...'

        mids = {}
        for name in full_patches['links']:
            url = full_patches['links'][name]

            fp = urlopen(url)
            try:
                link_data = fp.read()
            finally:
                fp.close()
示例#12
0
文件: stats.py 项目: aliguori/patches
# Authors:
#  Anthony Liguori <*****@*****.**>
#
# This work is licensed under the terms of the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.
#

import data, sys

def is_reviewed(patch):
    for tag in patch['tags']:
        if tag.startswith('Reviewed-by: '):
            return True
    return False

patches = data.parse_json(sys.stdin.read())

total_series = 0
total_patches = 0
total_reviews = 0
total_obsolete = 0
total_broken = 0
total_committed = 0
total_not_builds = 0
total_not_applies = 0
total_unreviewed = 0

for series in patches:
    total_series += 1

    is_broken = "broken" in series and series["broken"]
示例#13
0
    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()