Exemple #1
0
 def post(self):
     data = StringIO(request.data)
     try:
         plugin = Plugin.create_from_zip(data)
     except ValidationError as e:
         return {'result': 'error', 'message': "%s" % e}
     return {'result': 'success', 'plugin': plugin.metadata}
Exemple #2
0
def plugin_upload():
    message = None
    if request.method == 'POST':
        # check if the post request has the file part
        if 'file' not in request.files:
            message = 'No file part'
        else:
            file = request.files['file']
            # if user does not select file, browser also
            # submit a empty part without filename
            if file.filename == '':
                message = 'No selected file'
            elif file and '.' in file.filename and \
                    file.filename.rsplit('.', 1)[1] == 'zip':
                file.filename = secure_filename(file.filename)
                # Create plugin
                try:
                    plugin = Plugin.create_from_zip(file, file.filename)
                    message = 'Plugin {} version {} created'.format(
                        plugin.name, plugin.version)
                except ValidationError as e:
                    render_error('<b>{}</b> is not valid {}'.format(key, e))
            else:
                message = 'File does not have a zip extension'
    log("Plugin upload message: %s" % message)
    return render_template('upload.html', message=message)
 def post(self):
     data = StringIO(request.data)
     try:
         plugin = Plugin.create_from_zip(data)
     except ValidationError as e:
         return {'result': 'error', 'message': "%s" % e}
     return {'result': 'success', 'plugin': plugin.metadata}
def plugin_upload():
    message = None
    if request.method == 'POST':
        # check if the post request has the file part
        if 'file' not in request.files:
            message = 'No file part'
        else:
            file = request.files['file']
            # if user does not select file, browser also
            # submit a empty part without filename
            if file.filename == '':
                message = 'No selected file'
            elif file and '.' in file.filename and \
                    file.filename.rsplit('.', 1)[1] == 'zip':
                file.filename = secure_filename(file.filename)
                # Create plugin
                try:
                    plugin = Plugin.create_from_zip(file, file.filename)
                    message = 'Plugin {} version {} created'.format(plugin.name, plugin.version)
                except ValidationError as e:
                    render_error('<b>{}</b> is not valid {}'.format(key, e))
            else:
                message = 'File does not have a zip extension'
    log("Plugin upload message: %s" % message)
    return render_template('upload.html', message=message)
def app_bootstrap():
    """Load all zipfile plugins from the zipfiles folder"""
    zipfolder = os.path.join(os.path.dirname(__file__), 'zipfiles')
    if os.path.isdir(zipfolder):
        for path in [f for f in os.listdir(zipfolder)
                     if (os.path.isfile(os.path.join(zipfolder, f))
                     and f.endswith('.zip'))]:
            try:
                plugin = Plugin.create_from_zip(open(os.path.join(zipfolder, path)))
                log("Plugin: %s has been succesfully loaded" % plugin.key)
            except ValidationError as e:
                log("Plugin file: %s could not be loaded: %s" % (path, e))
Exemple #6
0
def app_bootstrap():
    """Load all zipfile plugins from the zipfiles folder"""
    zipfolder = os.path.join(os.path.dirname(__file__), 'zipfiles')
    if os.path.isdir(zipfolder):
        for path in [
                f for f in os.listdir(zipfolder) if
            (os.path.isfile(os.path.join(zipfolder, f)) and f.endswith('.zip'))
        ]:
            try:
                plugin = Plugin.create_from_zip(
                    open(os.path.join(zipfolder, path)))
                log("Plugin: %s has been succesfully loaded" % plugin.key)
            except ValidationError as e:
                log("Plugin file: %s could not be loaded: %s" % (path, e))