Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
html.append("<hr>")
# Listing
html.append("")
html.append("")
html.append(
" "
"")
html.append("")
html.append("")
if davres.path in ("", "/"):
html.append(
"")
else:
parentUrl = util.getUriParent(davres.getHref())
html.append("")
# Ask collection for member info list
dirInfoList = davres.getDirectoryInfo()
if dirInfoList is None:
# No pre-build info: traverse members
dirInfoList = []
childList = davres.getDescendants(depth="1", addSelf=False)
for res in childList:
di = res.getDisplayInfo()
href = res.getHref()
infoDict = {"href": href,
"class": "",
"displayName": res.getDisplayName(),<table><thead><tr><th>Name</th> <th>Type</th> <th class="right">Size</th><th class="right">Last modified</th> </tr></thead><tbody><tr><td>Top level share</td> <td></td> <td></td> <td></td> </tr><tr><td><a href="" + parentUrl +
"">Parent Directory</a></td> <td></td> <td></td> <td></td> </tr></tbody></table>
"PROPPATCH",
"MKCOL",
"COPY",
"MOVE",
"LOCK",
"UNLOCK",
]
# Enable automatic keep-alive:
protocol_version = "HTTP/1.1"
server_version = "WsgiDAV/{} ExtServer/{} {} Python {}".format(
__version__,
_version,
BaseHTTPServer.BaseHTTPRequestHandler.server_version,
util.PYTHON_VERSION,
)
def log_message(self, *args):
pass
# BaseHTTPServer.BaseHTTPRequestHandler.log_message(self, *args)
def log_request(self, *args):
pass
# BaseHTTPServer.BaseHTTPRequestHandler.log_request(self, *args)
def getApp(self):
# We want fragments to be returned as part of
"height='0' style=''visibility: hidden;'>")
html.append("")
html.append("")
# Title
html.append("<h1>Index of {}</h1>".format(displaypath))
# Add DAV-Mount link and Web-Folder link
links = []
if dirConfig.get("davmount"):
links.append("<a title="Open this folder in a WebDAV client.">Mount</a>".format(util.makeCompleteUrl(environ)))
if dirConfig.get("ms_mount"):
links.append("<a title="Open as Web Folder (requires Microsoft Internet Explorer)">Open as Web Folder</a>"
.format(util.makeCompleteUrl(environ)))
# html.append("<a href="">Open setup.py as WebDAV</a>"
# .format(util.makeCompleteUrl(environ)))
if links:
html.append("<p>{}</p>".format(" – ".join(links)))
html.append("<hr>")
# Listing
html.append("")
html.append("")
html.append(
" "
"")
html.append("")
html.append("")<table><thead><tr><th>Name</th> <th>Type</th> <th class="right">Size</th><th class="right">Last modified</th> </tr></thead><tbody></tbody></table>
return util.send_status_response(environ, start_response, error_list[0][1])
# Multiple errors, or error on one single child
multistatusEL = xml_tools.make_multistatus_el()
for refurl, e in error_list:
# assert refurl.startswith("http:")
assert refurl.startswith("/")
assert isinstance(e, DAVError)
responseEL = etree.SubElement(multistatusEL, "{DAV:}response")
etree.SubElement(responseEL, "{DAV:}href").text = refurl
etree.SubElement(responseEL, "{DAV:}status").text = "HTTP/1.1 {}".format(
get_http_status_string(e)
)
return util.send_multi_status_response(environ, start_response, multistatusEL)
def lock_string(lock_dict):
"""Return readable rep."""
if not lock_dict:
return "Lock: None"
if lock_dict["expire"] < 0:
expire = "Infinite ({})".format(lock_dict["expire"])
else:
expire = "{} (in {} seconds)".format(
util.get_log_time(lock_dict["expire"]), lock_dict["expire"] - time.time()
)
return "Lock(<{}..>, '{}', {}, {}, depth-{}, until {}".format(
# first 4 significant token characters
lock_dict.get("token", "?" * 30)[18:22],
lock_dict.get("root"),
lock_dict.get("principal"),
lock_dict.get("scope"),
lock_dict.get("depth"),
expire,
)
from wsgidav.dav_error import (
DAVError,
HTTP_FORBIDDEN,
HTTP_INTERNAL_ERROR,
PRECONDITION_CODE_ProtectedProperty,
)
from wsgidav.dav_provider import DAVCollection, DAVNonCollection, DAVProvider
from wsgidav.util import join_uri
import os
import stat
__docformat__ = "reStructuredText en"
_logger = util.get_module_logger(__name__)
BUFFER_SIZE = 8192
# ============================================================================
# Fake hierarchical repository
# ============================================================================
"""
This is a dummy 'database', that serves as an example source for the
VirtualResourceProvider.
All files listed in resPathList are expected to exist in FILE_FOLDER.
"""
FILE_FOLDER = r"c:\temp\virtfiles"
_resourceData = [
{
opts = {"url": "http://localhost:5984/", # CouchDB server
"dbName": "wsgidav-props", # Name of DB to store the properties
}
"""
from __future__ import print_function
from uuid import uuid4
from wsgidav import compat, util
import couchdb
__docformat__ = "reStructuredText"
_logger = util.get_module_logger(__name__)
# ============================================================================
# CouchPropertyManager
# ============================================================================
class CouchPropertyManager(object):
"""Implements a property manager based on CouchDB."""
def __init__(self, options):
self.options = options
self._connect()
def __del__(self):
self._disconnect()
def __init__(self, config):
self.config = copy.deepcopy(DEFAULT_CONFIG)
util.deep_update(self.config, config)
config = self.config
# Evaluate configuration and set defaults
_check_config(config)
self.verbose = config.get("verbose", 3)
hotfixes = config.get("hotfixes", {})
self.re_encode_path_info = hotfixes.get("re_encode_path_info", None)
if self.re_encode_path_info is None:
self.re_encode_path_info = compat.PY3
self.unquote_path_info = hotfixes.get("unquote_path_info", False)
lock_storage = config.get("lock_manager")