Esempio n. 1
0
  def __init__(self):
    filters = Configuration.get_instance().get_module_config("storage_filter")
    if filters is None:
      raise ValueError("Storage filter is not present")

    super(StoreFilter, self).__init__(filters)
    self._filter_types["dict"] = self._filter_dict
    self._filter_types["list"] = self._filter_list
 def __init__(self, auto_update=True, time: str="0:0:30"):
   self.cfg = Configuration.get_instance()
   self._storages = {}
   self._auto_update = auto_update
   self._update_period = self._parsetime(time)
   self._result_key_items = {
     "path": "<path>",
     "files": "<files>"
   }
Esempio n. 3
0
  def __init__(self):
    self.cfg = Configuration.get_instance()
    self._log = alogger.getLogger(__name__, cfg=self.cfg)
    self._apply_settings()
    self._flask = Flask(__name__)
    self._flask.register_error_handler(404, self._error_404_handler)
    self._flask.register_error_handler(405, self._error_405_handler)
    self._flask.register_error_handler(500, self._error_500_handler)
    self._response_wrapper = ResponseWrapperFactory.get_wrapper(self._settings["output"])

    # serve static content, please use that possibility only for testing.
    # in production please use nginx, apache, etc for this.
    if self._settings["static_enabled"]:
      self._log.info("Static content serving enabled, serving \"%s\" at mountpoint \"%s\"" %
                     (self._settings["static_path"], self._settings["static_endpoint"]))
      self._flask.static_folder = self._settings["static_path"]
      self.serve_static_content()
Esempio n. 4
0
def load(allowed_views: list = None, disabled_views: list = None):
    """
  Dynamic sub-modules loading routine

  Replaces __ALL__ = [] construction and makes that automatically with logging possibility

  Compatible: Python 2.7, 3.x
  """
    import os
    import types
    from alist.logger import alogger
    from alist.config import Configuration

    view_extension = ".py"

    cfg = Configuration.get_instance()
    log = alogger.getLogger(__name__, cfg=cfg)
    mod_list = get_modules(os.path.dirname(__file__), view_extension)

    # load only allowed views
    if allowed_views is not None and len(allowed_views) != 0:
        mod_list = list(filter(lambda x: x in allowed_views, mod_list))

    # filter views from to be loaded
    if disabled_views is not None and len(disabled_views) != 0:
        mod_list = list(filter(lambda x: x not in disabled_views, mod_list))

    log.debug("Loading filtered list of views in the namespace %s: %s", __name__, mod_list)

    #  append namespace to module
    mod_list = list(map(lambda x: "%s.%s" % (__name__, x), mod_list))
    for mod in mod_list:
        module = get_loaded_module(__import__(mod, globals(), [], []), mod)
        # Call view init method if present
        if (
            module is not None
            and "__init__" in module.__dict__
            and isinstance(module.__dict__["__init__"], types.FunctionType)
        ):
            module.__init__()
 def __init__(self, auto_update=True, time: str="0:0:30"):
   self._log = alogger.getLogger(__name__, Configuration.get_instance())
   self._storage_list_url = "{0}?q=list"
   self._storage_view_url = "{0}?q=view&storage={1}"
   super(StorageApiProvider, self).__init__(auto_update, time)