Example #1
0
                    filename = 'PASTED%s' % (file_extensions.get(inp_format), )
                else:
                    raise HTTP(
                        400,
                        'Expecting a "file" argument with an input file or a "content" argument with the contents of in input file'
                    )
                write_input_files(request, working_dir,
                                  [(INPUT_FILENAME, upload_stream)])
                prov_info = {
                    'filename': filename,
                    'dateTranslated': datetime.datetime.utcnow().isoformat(),
                }
                if request.vars.dataDeposit:
                    prov_info['dataDeposit'] = request.vars.dataDeposit
                write_ext_proc_content(
                    request,
                    working_dir, [(PROV_FILENAME, json.dumps(prov_info))],
                    encoding='utf-8')
                orig_args.update(prov_info)
                write_ext_proc_content(
                    request,
                    working_dir,
                    [(RETURN_ATT_FILENAME, json.dumps(orig_args))],
                    encoding='utf-8')

    if output == 'provenance':
        PROV_FILEPATH = os.path.join(working_dir, PROV_FILENAME)
        response.view = 'generic.json'
        return json.load(codecs.open(PROV_FILEPATH, 'rU', encoding='utf-8'))
    if output == 'input':
        response.headers['Content-Type'] = 'text/plain'
        return open(INPUT_FILEPATH, 'rU').read()
                    filename = upf.filename
                elif request.vars.content is not None:
                    upload_stream = request.vars.content # stream is a bad name, but write_input_files does the write thing.
                    file_extensions = {'nexson':'.json', 'nexus':'.nex', 'nexml':'.nexml', 'newick':'.tre', 'relaxedphyliptree':'.tre'}
                    filename = 'PASTED%s' % (file_extensions.get(inp_format),)
                else:
                    raise HTTP(400, 'Expecting a "file" argument with an input file or a "content" argument with the contents of in input file')
                write_input_files(request, working_dir, [(INPUT_FILENAME, upload_stream)])
                prov_info = {
                    'filename' : filename,
                    'dateTranslated': datetime.datetime.utcnow().isoformat(),
                }
                if request.vars.dataDeposit:
                    prov_info['dataDeposit'] = request.vars.dataDeposit
                write_ext_proc_content(request,
                                       working_dir,
                                       [(PROV_FILENAME, json.dumps(prov_info))],
                                       encoding='utf-8')
                orig_args.update(prov_info)
                write_ext_proc_content(request,
                                       working_dir,
                                       [(RETURN_ATT_FILENAME, json.dumps(orig_args))],
                                       encoding='utf-8')

    if output == 'provenance':
        PROV_FILEPATH =  os.path.join(working_dir, PROV_FILENAME)
        response.view = 'generic.json'
        return json.load(codecs.open(PROV_FILEPATH, 'rU', encoding='utf-8'))
    if output == 'input':
        response.headers['Content-Type'] = 'text/plain'
        return open(INPUT_FILEPATH, 'rU').read()
    NEXML_FILEPATH = os.path.join(working_dir, NEXML_FILENAME)