Пример #1
0
def get_downloads(level=None, weight=None, character=None, label=None, **kwds):
    keys = [
        'download', 'download_file', 'tempfile', 'format', 'number', 'bitprec'
    ]
    info = get_args(request, level, weight, character, label, keys=keys)
    if 'download' not in info:
        emf_logger.critical(
            "Download called without specifying what to download! info={0}".
            format(info))
        return ""
    emf_logger.debug("in get_downloads: info={0}".format(info))
    if info['download'] == 'file':
        # there are only a certain number of fixed files that we want people to download
        filename = info['download_file']
        if filename == "web_modforms.py":
            dirname = emf.app.root_static_folder
            try:
                emf_logger.debug("Dirname:{0}, Filename:{1}".format(
                    dirname, filename))
                return send_from_directory(dirname,
                                           filename,
                                           as_attachment=True,
                                           attachment_filename=filename)
            except IOError:
                info['error'] = "Could not find  file! "
    if info['download'] == 'coefficients':
        info['tempfile'] = "/tmp/tmp_web_mod_form.txt"
        return get_coefficients(info)
    if info['download'] == 'object':
        return download_web_modform(info)
        info['error'] = "Could not find  file! "
Пример #2
0
def get_downloads(level=None, weight=None, character=None, label=None, **kwds):
    keys = ['download', 'download_file', 'tempfile', 'format', 'number','bitprec']
    info = get_args(request, level=level, weight=weight, character=character, label=label, keys=keys)
    if 'download' not in info:
        emf_logger.critical("Download called without specifying what to download! info={0}".format(info))
        return ""
    emf_logger.debug("in get_downloads: info={0}".format(info))
    if info['download'] == 'coefficients':
        info['tempfile'] = "/tmp/tmp_web_mod_form.txt"
        return get_coefficients(info)
    if info['download'] == 'file':
        # there are only a certain number of fixed files that we want people to download
        filename = info['download_file']
        if filename == "web_modforms.py":
            dirname = emf.app.root_static_folder
            try:
                emf_logger.debug("Dirname:{0}, Filename:{1}".format(dirname, filename))
                return send_from_directory(dirname, filename, as_attachment=True, attachment_filename=filename)
            except IOError:
                info['error'] = "Could not find file! "