Esempio n. 1
0
def report_feedback(userid):
    """
    """
    print "[statistics] Starting feedback send"
    fbpath = makepath('feedback.json')
    if not path_exists(fbpath):
        feedback = []
    else:
        feedback = jsonload(fbpath)
    if len(feedback) > 0:
        data = {'feedback' : feedback, 'userid' : userid}
        network_POST('/stats/report_feedback', data)
        jsondump(makepath('feedback.json'), [])
    print '[statistics] Finished feedback send'

    altpath = makepath('feedback.txt')
    if path_exists(altpath):
        feedback = fileload(altpath)
        data = {'feedback' : feedback, 'userid' : userid}
        network_POST('/stats/report_legacy_feedback', data)
        command('rm', altpath)
Esempio n. 2
0
def make_aggregate_plot_over_all_seeds(out_dir):
    tracess = []
    for traces_fname in out_dir.glob('traces*seed*.json'):
        tracess.append(util.jsonload(traces_fname))
    plot_traces(tracess, out=out_dir / 'traces_aggregate.png')
Esempio n. 3
0
def spiceMerge(spices, username):
    """
    Manages the merger of a spice into the development repository.

    @param spices: list of (spicename, dirname)
    """
    log('[spicemanager] In func:spiceMerge')
    goto_dir(makepath('spicerackdev'))
    command('git', 'pull')
    goto_dir(makepath(''))

    spice_to_metadata = {}
    for dirname in spices:
        data = jsonload(makepath('spicerackdev', dirname, 'metadata.json'))
        spicename = data['name']
        if 'spicename' not in data:
            data['spicename'] = spicename
        if 'width' not in data:
            data['width'] = 0
            data['height'] = 0
            data['dependencies'] = []

        Statsd.increment('spices.spicerackdev.%s' % spicename.replace(' ', '-'))

        mid = get('spice-id:%s' % spicename.replace(' ', '-'))
        if mid is None:
            mid = str(uuid.uuid4())
            put('spice-id:%s' % spicename.replace(' ', '-'), mid)

        log('[spicemanager] Processing %s %s' % (spicename, mid))

        version = 1 + int(dget('version:%s' % mid, 0))
        put('version:%s' % mid, version)
        log('[spicemanager] Version: %s' % version)

        spice_to_metadata[mid] = {
            'spicename' : data['spicename'],
            'gituser' : username,
            'author' : data['author'],
            'tagline' : data['description'],
            'description' : data['description'],
            'version' : version,
            'hotkey' : False,
            'main' : data['main'],
            'width' : data['width'],
            'height' : data['height'],
            'dependencies' : data['dependencies']
            }

        put('metadata:%s' % mid, spice_to_metadata[mid])
        
        jsondump(makepath('spicerackdev', dirname, 'metadata.json'), spice_to_metadata[mid])
                   
        # Tar the spice directory into /spices/{mid}.tar.gz
        command('tar', '-cvf', makepath('spices', '%s.tar.gz' % mid), makepath('spicerackdev', dirname))

        # Copy the icon file into /icons
        iconpath = makepath('spicerackdev', dirname, 'icon.png')
        command('cp', '-f', iconpath, makepath('icons', '%s.png' % mid))
        
        iconpath = makepath(dirname, 'icon.png')
        if not os.path.exists(iconpath):
            command('tar', '-cvf', makepath('spices', '%s.tar.gz' % mid), makepath('spicerackdev', dirname))
        else:
            iconpath = iconpath.strip('icon.png')
            command('tar',
                    '-cvf',
                    makepath('spices', '%s.tar.gz' % mid),
                    makepath('spicerackdev', dirname),
                    '--directory=%s' % iconpath,
                    'icon.png')

        goto_dir(makepath('spicerackdev'))
        command('git', 'stash')
        goto_dir(makepath(''))

        heroku_metadata = {
            'spicename' : data['spicename'],
            'gituser' : username,
            'author' : data['author'],
            'tagline' : data['description'],
            'description' : data['description'],
            'version' : version,
            'hotkey' : False,
            'main' : data['main']
            }

        log('HEROKU: %s %s', type(heroku_metadata), heroku_metadata)
        for key, val in heroku_metadata.iteritems():
            log('KEY %s VAL %s %s', key, type(val), val)

        resp, content = send_post({str(mid) : heroku_metadata}, '/spices/refresh')
        log('[spicemanager] Heroku response: %s' % str(resp))

    return 'success'