Esempio n. 1
0
def Convert(req):
    #for when this is running on the same server as galaxy
    #just use the local files directly
    try:
        fs = binascii.unhexlify(req.GET["file"])
    except:
        return HTTPBadRequest_Param("file")
    try:
        ref = Referencers[req.GET["type"]]
    except:
        return HTTPBadRequest_Param("type")
    #Build the index file
    if not os.path.exists(converted):
        os.makedirs(converted)
    (jobid, f) = Jobs.add_job("local", fs, 7 * 24 * 60 * 60, ref=ref)
    resp = render_to_response(templates + "upload.pt", {"file": f, "jobid": str(jobid)}, request=req)
    resp.cache_expires(0)
    return resp
Esempio n. 2
0
def Upload(req):
    #uploading from a remote server
    fs = req.POST.getall("uploadedfiles[]")
    if platform.system() == "Windows":  # Windows has an extra .file in here for some reason
        for f in fs:
            if hasattr(f.file, "file"):
                f.file = f.file.file
    for f in fs:
        f.file.seek(0)
    #Build the index file
    if not os.path.exists(converted):
        os.makedirs(converted)
    try:
        cleanup = req.POST["delete"]
    except:
        cleanup = 7
    (jobid, f) = Jobs.add_job("remote", fs, cleanup * 24 * 60 * 60)
    json_response = '{"file":"' + f + '","jobid":' + str(jobid) + '}\r\n'
    resp = Response(json_response)
    resp.cache_expires(0)
    return resp
Esempio n. 3
0
def ConvertUrl(req):
    _read_shortcut_params(req)
    default_hash = ""
    try:
        req_scan = req.GET["scan"]
        default_hash = "#S0;None;%s" % req_scan
    except KeyError:
        pass

    try:
        url = req.GET["url"]
    except:
        return HTTPBadRequest_Param("url")
    try:
        ref = Referencers[req.GET["type"]]
    except:
        return HTTPBadRequest_Param("type")
    #Build the index file
    if not os.path.exists(converted):
        os.makedirs(converted)
    (jobid, f) = Jobs.add_job("url", str(url), 7 * 24 * 60 * 60, ref=ref)
    resp = render_to_response(templates + "upload.pt", {"file": f, "jobid": str(jobid), "default_hash": default_hash}, request=req)
    resp.cache_expires(0)
    return resp