Disable client.check by default.

This commit is contained in:
dzhuang 2019-10-02 23:25:33 +08:00 committed by Evgeny Ezhov
parent c90ee856fd
commit 64bbd967bc
4 changed files with 16 additions and 3 deletions

View file

@ -42,6 +42,11 @@ class Test(TestCommand):
errno = pytest.main(self.pytest_args)
sys.exit(errno)
try:
long_description = open('README.rst', encoding="utf-8").read()
except TypeError:
long_description = open('README.rst').read()
setup(
name='webdavclient3',
version=version,
@ -54,7 +59,7 @@ setup(
cmdclass={'install': Install, 'test': Test},
description='WebDAV client, based on original package https://github.com/designerror/webdav-client-python but '
'uses requests instead of PyCURL',
long_description=open('README.rst').read(),
long_description=long_description,
author='Evgeny Ezhov',
author_email='ezhov.evgeny@gmail.com',
url='https://github.com/ezhov-evgeny/webdav-client-python-3',

View file

@ -172,6 +172,10 @@ class Client(object):
)
if response.status_code == 507:
raise NotEnoughSpace()
if response.status_code == 404:
raise RemoteResourceNotFound(path=path)
if response.status_code == 405:
raise MethodNotSupported(name=action, server=hostname)
if response.status_code >= 400:
raise ResponseErrorCode(url=self.get_url(path), code=response.status_code, message=response.content)
return response
@ -269,6 +273,9 @@ class Client(object):
:param remote_path: (optional) path to resource on WebDAV server. Defaults is root directory of WebDAV.
:return: True if resource is exist or False otherwise
"""
if not self.webdav.do_check:
return True
urn = Urn(remote_path)
try:
response = self.execute_request(action='check', path=urn.quote())

View file

@ -22,7 +22,7 @@ class WebDAVSettings(ConnectionSettings):
ns = "webdav:"
prefix = "webdav_"
keys = {'hostname', 'login', 'password', 'token', 'root', 'cert_path', 'key_path', 'recv_speed', 'send_speed',
'verbose'}
'verbose', 'do_check'}
hostname = None
login = None
@ -34,6 +34,7 @@ class WebDAVSettings(ConnectionSettings):
recv_speed = None
send_speed = None
verbose = None
do_check = False
def __init__(self, options):

View file

@ -55,7 +55,7 @@ class MethodNotSupported(WebDavException):
self.server = server
def __str__(self):
return "Method {name} not supported for {server}".format(name=self.name, server=self.server)
return "Method '{name}' not supported for {server}".format(name=self.name, server=self.server)
class ConnectionException(WebDavException):