How to use the wsgidav.util.get_module_logger function in WsgiDAV

To help you get started, we’ve selected a few WsgiDAV examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mar10 / wsgidav / tests / test_util.py View on Github external
def testCliLogging(self):
        """CLI initializes logging."""
        config = {"verbose": 3, "enable_loggers": ["test"]}
        init_logging(config)

        _baseLogger = logging.getLogger(BASE_LOGGER_NAME)
        _enabledLogger = get_module_logger("test")
        _disabledLogger = get_module_logger("test2")

        _baseLogger.debug("_baseLogger.debug")
        _baseLogger.info("_baseLogger.info")
        _baseLogger.warning("_baseLogger.warning")
        _baseLogger.error("_baseLogger.error")

        _enabledLogger.debug("_enabledLogger.debug")
        _enabledLogger.info("_enabledLogger.info")
        _enabledLogger.warning("_enabledLogger.warning")
        _enabledLogger.error("_enabledLogger.error")

        _disabledLogger.debug("_disabledLogger.debug")
        _disabledLogger.info("_disabledLogger.info")
        _disabledLogger.warning("_disabledLogger.warning")
        _disabledLogger.error("_disabledLogger.error")
github mar10 / wsgidav / wsgidav / server / ext_wsgiutils_server.py View on Github external
from http import client as http_client  # py3
except ImportError:
    import httplib as http_client

try:
    from http import server as BaseHTTPServer  # py3
except ImportError:
    import BaseHTTPServer

try:
    import socketserver  # py3
except ImportError:
    import SocketServer as socketserver


_logger = util.get_module_logger(__name__)

_version = 1.0

SERVER_ERROR = """\

  
     <title>Server Error</title>
  
  
     <h1>Server Error</h1>
     A server error has occurred.  Please contact the system administrator for
     more information.
  

"""
github mar10 / wsgidav / wsgidav / dc / base_dc.py View on Github external
TODO: Work In Progress / Subject to change

"""
from __future__ import print_function
from hashlib import md5
from wsgidav import compat, util

import abc
import six
import sys


__docformat__ = "reStructuredText"

logger = util.get_module_logger(__name__)


@six.add_metaclass(abc.ABCMeta)
class BaseDomainController(object):
    #: A domain controller MAY list these values as
    #: `environ["wsgidav.auth.permissions"] = (, ...)`
    known_permissions = ("browse_dir", "delete_resource", "edit_resource")
    #: A DC may list these values as `environ["wsgidav.auth.roles"] = (, ...)`
    known_roles = ("admin", "editor", "reader")

    def __init__(self, wsgidav_app, config):
        self.wsgidav_app = wsgidav_app
        self.config = config

    def __str__(self):
        return "{}()".format(self.__class__.__name__)
github mar10 / wsgidav / wsgidav / debug_filter.py View on Github external
Configured like::

        debug_litmus = ["notowner_modify", "props: 16", ]

"""
from wsgidav import compat, util
from wsgidav.middleware import BaseMiddleware
from wsgidav.util import safe_re_encode

import sys
import threading


__docformat__ = "reStructuredText"

_logger = util.get_module_logger(__name__)


class WsgiDavDebugFilter(BaseMiddleware):
    def __init__(self, wsgidav_app, next_app, config):
        super(WsgiDavDebugFilter, self).__init__(wsgidav_app, next_app, config)
        self._config = config
        # self.out = sys.stdout
        self.passedLitmus = {}
        # These methods boost verbose=2 to verbose=3
        self.debug_methods = config.get("debug_methods", [])
        # Litmus tests containing these string boost verbose=2 to verbose=3
        self.debug_litmus = config.get("debug_litmus", [])
        # Exit server, as soon as this litmus test has finished
        self.break_after_litmus = [
            # "locks: 15",
        ]
github mar10 / wsgidav / wsgidav / samples / mongo_dav_provider.py View on Github external
"pwd": None,               # ... and password
            }

"""
from bson.objectid import ObjectId
from pprint import pformat
from wsgidav import compat, util
from wsgidav.dav_provider import DAVCollection, DAVNonCollection, DAVProvider
from wsgidav.util import join_uri

import pymongo


__docformat__ = "reStructuredText"

_logger = util.get_module_logger(__name__)


# ============================================================================
#
# ============================================================================
class ConnectionCollection(DAVCollection):
    """Root collection, lists all mongo databases."""

    def __init__(self, path, environ):
        DAVCollection.__init__(self, path, environ)
        self.conn = self.provider.conn

    def get_member_names(self):
        return [name.encode("utf8") for name in self.conn.database_names()]

    def get_member(self, name):
github mar10 / wsgidav / wsgidav / wsgidav_app.py View on Github external
from wsgidav.util import (
    dynamic_import_class,
    dynamic_instantiate_middleware,
    safe_re_encode,
)

import copy
import inspect
import platform
import sys
import time


__docformat__ = "reStructuredText"

_logger = util.get_module_logger(__name__)


def _check_config(config):
    errors = []

    mandatory_fields = ("provider_mapping",)
    for field in mandatory_fields:
        if field not in config:
            errors.append("Missing required option '{}'.".format(field))

    deprecated_fields = {
        "acceptbasic": "http_authenticator.accept_basic",
        "acceptdigest": "http_authenticator.accept_digest",
        "catchall": "error_printer.catch_all",
        "defaultdigest": "http_authenticator.default_to_digest",
        "dir_browser.app_class": "middleware_stack",
github mar10 / wsgidav / wsgidav / fs_dav_provider.py View on Github external
and :class:`~wsgidav.fs_dav_provider.FolderResource` to represent files and
directories respectively.
"""
from wsgidav import compat, util
from wsgidav.dav_error import DAVError, HTTP_FORBIDDEN
from wsgidav.dav_provider import DAVCollection, DAVNonCollection, DAVProvider

import os
import shutil
import stat
import sys


__docformat__ = "reStructuredText"

_logger = util.get_module_logger(__name__)

BUFFER_SIZE = 8192


# ========================================================================
# FileResource
# ========================================================================
class FileResource(DAVNonCollection):
    """Represents a single existing DAV resource instance.

    See also _DAVResource, DAVNonCollection, and FilesystemProvider.
    """

    def __init__(self, path, environ, file_path):
        super(FileResource, self).__init__(path, environ)
        self._file_path = file_path
github mar10 / wsgidav / wsgidav / dc / nt_dc.py View on Github external
**Using for a network domain**
   This class is being tested for a network domain (I'm setting one up to test).

"""
from __future__ import print_function
from wsgidav import compat, util
from wsgidav.dc.base_dc import BaseDomainController

import win32net
import win32netcon
import win32security


__docformat__ = "reStructuredText"
_logger = util.get_module_logger(__name__)


class NTDomainController(BaseDomainController):
    def __init__(self, wsgidav_app, config):
        super(NTDomainController, self).__init__(wsgidav_app, config)
        # auth_conf = config["http_authenticator"]
        dc_conf = config.get("nt_dc", {})

        self.preset_domain = dc_conf.get("preset_domain")
        self.preset_server = dc_conf.get("preset_server")

    def __str__(self):
        return "{}({!r}, {!r})".format(
            self.__class__.__name__, self.preset_domain, self.preset_server
        )
github mar10 / wsgidav / wsgidav / prop_man / mongo_property_manager.py View on Github external
# This options are used with `mongod --auth`
            # The user must be created with db.addUser()
            "user": None,              # Authenticate with this user
            "pwd": None,               # ... and password
            }

"""
from __future__ import print_function
from wsgidav import compat, util

import pymongo


__docformat__ = "reStructuredText"

_logger = util.get_module_logger(__name__)

# We use these keys internally, so they must be protected
HIDDEN_KEYS = ("_id", "_url", "_title")

# MongiDB doesn't accept '.' in key names, so we have to escape it.
# Use a key that is unlikely to occur in proprty names
DOT_ESCAPE = "^"


def encode_mongo_key(s):
    """Return an encoded version of `s` that may be used as MongoDB key."""
    assert DOT_ESCAPE not in s
    return s.replace(".", DOT_ESCAPE)


def decode_mongo_key(key):