예제 #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
파일: notify.py 프로젝트: stefanha/patches
    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()