Esempio n. 1
0
def upload_to_s3():

    print "Upload page"
    session = bottle.request.environ.get('beaker.session')

    bucket = request.params.get('bucket')
    key = request.params.get('key')
    etag = request.params.get('etag')
    signed_url = s3.generate_signed_url(request.app.config["s3.conn"], bucket,
                                        key, 1500)  # Duration
    link = '<a href="{0}">{1}</a>'.format(signed_url, key.split('/')[-1])
    unsigned = "https://s3.amazonaws.com/{0}/{1}".format(bucket, key)

    return template("./views/upload_confirm.tpl",
                    signed_url=link,
                    unsigned=unsigned,
                    job_id="foo",
                    title="Turing - Upload Success!",
                    session=session)
Esempio n. 2
0
def get_job_info(request, job_id):

    item = dutils.get_job(request, job_id)
    pairs = []
    for k in item.keys():

        if k.startswith("i_") and k != 'i_ispublished':
            continue

        if k in ['submit_time', 'complete_time', 'start_time']:
            pairs.append([
                k,
                time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(item[k]))
            ])

        elif k in ['inputs']:
            link = '<a href="{0}">{1}</a>'.format(item[k][0]['src'],
                                                  item[k][0]['dest'])
            pairs.append([k, link])

        elif k in ['outputs']:
            if item["status"].lower() not in ["completed", "failed"]:
                continue

            for out in item[k]:
                target = out["dest"].split('/', 1)
                signed_url = s3.generate_signed_url(
                    request.app.config["s3.conn"],
                    target[0],  # Bucket name
                    target[1],  # Prefix
                    1500)  # Duration
                if signed_url:
                    link = '<a href="{0}">{1}</a>'.format(
                        signed_url, out["src"])
                else:
                    link = "<i>{0}</i>".format(out["src"])

                pairs.append([k, link])

        else:
            pairs.append([k, item[k]])

    return pairs
Esempio n. 3
0
def upload_to_s3():
    
    print "Upload page"
    session = bottle.request.environ.get('beaker.session')
    
    bucket  =  request.params.get('bucket')
    key     =  request.params.get('key')
    etag    =  request.params.get('etag')
    signed_url = s3.generate_signed_url(request.app.config["s3.conn"],
                                        bucket,
                                        key,
                                        1500)   # Duration
    link = '<a href="{0}">{1}</a>'.format(signed_url,
                                          key.split('/')[-1])
    unsigned = "https://s3.amazonaws.com/{0}/{1}".format(bucket, key)
        
    return template("./views/upload_confirm.tpl",
                    signed_url=link,
                    unsigned = unsigned,
                    job_id="foo",
                    title="Turing - Upload Success!",
                    session=session)
Esempio n. 4
0
def get_job_info(request, job_id):

    item = dutils.get_job(request, job_id)
    pairs = []
    for k in item.keys():

        if k.startswith("i_") and k != 'i_ispublished':
            continue
        
        if k in ['submit_time', 'complete_time', 'start_time']:            
            pairs.append([k, time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(item[k]))])
        
        elif k in ['inputs']:
            link       = '<a href="{0}">{1}</a>'.format(item[k][0]['src'], 
                                                        item[k][0]['dest'])
            pairs.append([k, link])
            
        elif k in ['outputs']:
            if item["status"].lower() not in ["completed", "failed"]:
                continue

            for out in item[k]:
                target = out["dest"].split('/', 1)
                signed_url = s3.generate_signed_url(request.app.config["s3.conn"],
                                                    target[0], # Bucket name
                                                    target[1], # Prefix
                                                    1500)      # Duration
                if signed_url :
                    link       = '<a href="{0}">{1}</a>'.format(signed_url, out["src"])
                else:
                    link       = "<i>{0}</i>".format(out["src"])

                pairs.append([k, link])
                        
        else:
            pairs.append([k, item[k]])

    return pairs