def deletePluginHandler(self, request):
        _plugin = request.form.get("pluginName")
        _component = request.form.get("component")
        if Path("app/plugins/{}.py".format(_plugin)).exists():
            # unregister component from api
            if _component == "Processor":
                _v1.unregister_processor_plugin(_plugin)
            elif _component == "Exporter":
                _v1.unregister_exporter_plugin(_plugin)
            elif _component == "Importer":
                _v1.unregister_importer_plugin(_plugin)
            elif _component == "Data":
                _v1.unregister_data_plugin(_plugin)
            elif _component == "DatabaseExporter":
                _v1.unregister_database_exporter_plugin(_plugin)
            else:
                raise Error('Componente {} desconocido'.format(_component))

            print("holaaa")
            # delete plugin file
            Path("app/plugins/{}.py".format(_plugin)).unlink()
            # reload plugins
            plugin_loader.load_plugins()
            # remove plugin from sys.modules imports
            _pluginmodule = "app.plugins.{}".format(_plugin)
            if _pluginmodule in sys.modules:
                print("removing module: ", _pluginmodule)
                del sys.modules[_pluginmodule]
            return self._getAllPlugins()
        else:
            raise Error('Plugin {} not found'.format(_plugin))
示例#2
0
 def __call__(self, request: any):
     self._updatePagination(request)
     action = request.args.get("action")
     print("accion: ", action)
     if action is None:
         raise Error('No se ha seleccionado una acción')
     elif action not in self.actions:
         raise Error('Accion {} desconocida'.format(action))
     else:
         self.actions[action](request)
     return dataframeHandler.getAllData(self.pagination)
示例#3
0
 def __call__(self, request: any):
     self._updatePagination(request)
     file = request.files['file']
     action = request.args.get("action")
     if action is None:
         self.actions["default"](file)
     elif action not in self.actions:
         raise Error('Accion {} desconocida'.format(action))
     else:
         self.actions[action](file)
     return dataframeHandler.getAllData(self.pagination)
示例#4
0
 def __call__(self, request: any):
     print("ProcessorPluginExample called")
     self._updatePagination(request)
     action = request.args.get("action")
     if action is None:
         self.actions["default"](request)
     elif action not in self.actions:
         raise Error('Accion {} desconocida'.format(action))
     else:
         self.actions[action](request)
     return dataframeHandler.getAllData(self.pagination)
示例#5
0
 def __call__(self, request: any):
     self._updatePagination(request)
     action = request.args.get("action")
     print("accion: ", action)
     if action is None:
         self.actions["default"](request)
     elif action not in self.actions:
         raise Error('Accion {} desconocida'.format(action))
     else:
         self.actions[action](request)
     return self.filedata
 def __call__(self, request: any):
     response = None
     action = request.args.get("action")
     print("accion: ", action)
     if action is None:
         response = self.actions["default"](request)
     elif action not in self.actions:
         raise Error('Accion {} desconocida'.format(action))
     else:
         response = self.actions[action](request)
     return response
 def uploadPluginHandler(self, request):
     if request.files:
         _file = request.files.get("plugin")
         _componentName = re.search(
             'pluginName(.*)"',
             _file.read().decode("utf-8")).group(1).replace(
                 "=", "").replace("\"", "").replace("'", "").strip()
         _file.seek(0)
         _file.save(Path("app/plugins/{}.py".format(_componentName)))
         plugin_loader.load_plugins()
         return self._getAllPlugins()
     else:
         raise Error('No se ha proporcionado ningun archivo')
 def post(self):
     data = None
     components: Components = _v1._private.container[Components]
     plugins: Components = _v1._private.container[DatabaseExporterPlugins]
     pluginName = request.args.get('plugin')
     if pluginName == None:
         component = next(x for x in components if x.name == componentName )
         data = _v1._private.container[component.handler_class](request)
     else:
         plugin = None
         try:
             plugin = next(x for x in plugins if x.name == pluginName )
         except:
             raise Error('El plugin {} no existe o no se ha instalado'.format(pluginName))
         data = _v1._private.container[plugin.handler_class](request)
     return jsonify(data)
示例#9
0
 def post(self):
     data = None
     components: Components = _v1._private.container[Components]
     plugins: Components = _v1._private.container[ExporterPlugins]
     pluginName = request.args.get('plugin')
     if pluginName == None:
         component = next(x for x in components if x.name == componentName)
         data = _v1._private.container[component.handler_class](request)
     else:
         plugin = None
         try:
             plugin = next(x for x in plugins if x.name == pluginName)
         except:
             raise Error(
                 'El plugin {} no existe o no se ha instalado'.format(
                     pluginName))
         data = _v1._private.container[plugin.handler_class](request)
     result = send_file(data['file'],
                        as_attachment=True,
                        attachment_filename=data['filename'],
                        mimetype=data['mimetype'])
     result.headers["File-Name"] = data['filename']
     return result
示例#10
0
  def __init__(self, message):
    # call the parent class __init__
    Error.__init__(self)

    # store the message
    self.message = message
示例#11
0
 def defaultHandler(self, file):
     extension = Path(file.filename).suffix
     if extension not in self.fileHandlers:
         raise Error('Extensión {} no soportada'.format(extension))
     self.fileHandlers[extension](file)