Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _makeWsgiDAVApp(self, withAuthentication):
self.rootpath = os.path.join(gettempdir(), "wsgidav-test")
if not os.path.exists(self.rootpath):
os.mkdir(self.rootpath)
provider = FilesystemProvider(self.rootpath)
# config = DEFAULT_CONFIG.copy()
# config.update({
config = {
"provider_mapping": {"/": provider},
# None: dc.simple_dc.SimpleDomainController(user_mapping)
"http_authenticator": {"domain_controller": None},
"simple_dc": {"user_mapping": {"*": True}}, # anonymous access
"verbose": 1,
"enable_loggers": [],
"property_manager": None, # None: no property manager
"lock_manager": True, # True: use lock_manager.LockManager
}
if withAuthentication:
config["http_authenticator"].update(
def run(self):
print("WsgiDAVServerThread.run()...")
withAuthentication = True
self.rootpath = os.path.join(gettempdir(), "wsgidav-test")
if not os.path.exists(self.rootpath):
os.mkdir(self.rootpath)
provider = FilesystemProvider(self.rootpath)
# config = DEFAULT_CONFIG.copy()
# config.update({
config = {
"provider_mapping": {"/": provider},
"host": SERVER_HOST,
"port": SERVER_PORT,
# None: dc.simple_dc.SimpleDomainController(user_mapping)
"http_authenticator": {"domain_controller": None},
"simple_dc": {"user_mapping": {"*": True}}, # anonymous access
"verbose": 4,
"enable_loggers": [
# "http_authenticator",
# "lock_manager",
],
"debug_methods": [],
def run_wsgidav_server(with_auth, with_ssl, provider=None, **kwargs):
"""Start blocking WsgiDAV server (called as a separate process)."""
package_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
share_path = os.path.join(gettempdir(), "wsgidav-test")
if not os.path.exists(share_path):
os.mkdir(share_path)
if provider is None:
provider = FilesystemProvider(share_path)
# config = DEFAULT_CONFIG.copy()
# config.update({
config = {
"host": "127.0.0.1",
"port": 8080,
"provider_mapping": {"/": provider},
# None: dc.simple_dc.SimpleDomainController(user_mapping)
"http_authenticator": {"domain_controller": None},
"simple_dc": {"user_mapping": {"*": True}}, # anonymous access
"verbose": 1,
"enable_loggers": [],
"property_manager": True, # None: no property manager
"lock_manager": True, # True: use lock_manager.LockManager
}
def main():
root_path = gettempdir()
provider = FilesystemProvider(root_path)
config = {
"provider_mapping": {"/": provider},
"http_authenticator": {
"domain_controller": None # None: dc.simple_dc.SimpleDomainController(user_mapping)
},
"simple_dc": {"user_mapping": {"*": True}}, # anonymous access
"verbose": 1,
"enable_loggers": [],
"property_manager": True, # True: use property_manager.PropertyManager
"lock_manager": True, # True: use lock_manager.LockManager
}
app = WsgiDAVApp(config)
# For an example, use CherryPy
from cherrypy.wsgiserver import CherryPyWSGIServer
# :
# We allow a simple string as 'provider'. In this case we interpret
# it as a file system root folder that is published.
provider = FilesystemProvider(provider, readonly)
elif type(provider) in (dict,):
if "provider" in provider:
# Syntax:
# : {"provider": , "args": , "kwargs": : {"root":
if cli_opts.get("host"):
config["host"] = cli_opts.get("host")
if cli_opts.get("profile") is not None:
config["profile"] = True
if cli_opts.get("server") is not None:
config["server"] = cli_opts.get("server")
if cli_opts.get("ssl_adapter") is not None:
config["ssl_adapter"] = cli_opts.get("ssl_adapter")
# Command line overrides file only if -v or -q where passed:
if cli_opts.get("verbose") != DEFAULT_VERBOSE:
config["verbose"] = cli_opts.get("verbose")
if cli_opts.get("root_path"):
root_path = os.path.abspath(cli_opts.get("root_path"))
config["provider_mapping"]["/"] = FilesystemProvider(root_path)
if config["verbose"] >= 5:
# TODO: remove passwords from user_mapping
# config_cleaned = copy.deepcopy(config)
print("Configuration({}):\n{}".format(cli_opts["config_file"], pformat(config)))
if not config["provider_mapping"]:
parser.error("No DAV provider defined.")
# Quick-configuration of DomainController
auth = cli_opts.get("auth")
auth_conf = config.get("http_authenticator", {})
if auth and auth_conf.get("domain_controller"):
parser.error(
"--auth option can only be used when no domain_controller is configured"
)
def add_provider(self, share, provider, readonly=False):
"""Add a provider to the provider_map routing table."""
# Make sure share starts with, or is '/'
share = "/" + share.strip("/")
assert share not in self.provider_map
if compat.is_basestring(provider):
# Syntax:
# :
# We allow a simple string as 'provider'. In this case we interpret
# it as a file system root folder that is published.
provider = FilesystemProvider(provider, readonly)
elif type(provider) in (dict,):
if "provider" in provider:
# Syntax:
# : {"provider": , "args": , "kwargs": : {"root":