Пример #1
0
def api_upload_module():
    file_ = request.files['file']
    if not file_:
        abort(400)
    if not allowed_file(file_.filename, ['zip']):
        abort(403)

    # all is good, let's go !
    _, filename = tempfile.mkstemp()
    file_.save(filename)
    try:
        packaging.install_from_zip(filename)
    except (IOError, ValueError):
        abort(403)
    finally:
        try:
            os.remove(filename)
        except OSError:
            pass
    return ''
Пример #2
0
def api_upload_module():
    file_ = request.files['file']
    if not file_:
        abort(400)
    if not allowed_file(file_.filename, ['zip']):
        abort(403)

    # all is good, let's go !
    _, filename = tempfile.mkstemp()
    file_.save(filename)
    try:
        packaging.install_from_zip(filename)
    except (IOError, ValueError):
        abort(403)
    finally:
        try:
            os.remove(filename)
        except OSError:
            pass
    return ''
Пример #3
0
def api_install_module(module_name):
    try:
        io = StringIO()
        zipfile = urllib2.urlopen(urlparse.urljoin(STORE_URL,
            '/api/available_modules/%s/download' % module_name))
        io.write(zipfile.read())
        success = packaging.install_from_zip(io)
    except urllib2.HTTPError:
        abort(404)
    except IOError:
        abort(403)
    return jsonify({ 'success': success })
Пример #4
0
def api_install_module(module_name):
    try:
        io = StringIO()
        zipfile = urllib2.urlopen(
            urlparse.urljoin(
                STORE_URL, '/api/available_modules/%s/download' % module_name))
        io.write(zipfile.read())
        success = packaging.install_from_zip(io)
    except urllib2.HTTPError:
        abort(404)
    except IOError:
        abort(403)
    return jsonify({'success': success})