webdavclient3


Namewebdavclient3 JSON
Version 3.14.6 PyPI version JSON
download
home_pagehttps://github.com/ezhov-evgeny/webdav-client-python-3
SummaryWebDAV client, based on original package https://github.com/designerror/webdav-client-python but uses requests instead of PyCURL
upload_time2021-08-12 18:48:25
maintainer
docs_urlNone
authorEvgeny Ezhov
requires_python
licenseMIT License
keywords webdav client python module library packet yandex.disk dropbox google disk box 4shared
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            Python WebDAV Client 3
=========
[![Build Status](https://travis-ci.com/ezhov-evgeny/webdav-client-python-3.svg?branch=develop)](https://travis-ci.com/ezhov-evgeny/webdav-client-python-3)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ezhov-evgeny_webdav-client-python-3&metric=alert_status)](https://sonarcloud.io/dashboard?id=ezhov-evgeny_webdav-client-python-3)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ezhov-evgeny_webdav-client-python-3&metric=coverage)](https://sonarcloud.io/dashboard?id=ezhov-evgeny_webdav-client-python-3)
[![PyPI](https://img.shields.io/pypi/v/webdavclient3)](https://pypi.org/project/webdavclient3/) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/webdavclient3)  

Package webdavclient3 based on https://github.com/designerror/webdav-client-python but uses `requests` instead of `PyCURL`.
It provides easy way to work with WebDAV-servers.

Installation
------------
```bash
$ pip install webdavclient3
```

Sample Usage
------------
```python
from webdav3.client import Client
options = {
 'webdav_hostname': "https://webdav.server.ru",
 'webdav_login':    "login",
 'webdav_password': "password"
}
client = Client(options)
client.verify = False # To not check SSL certificates (Default = True)
client.session.proxies(...) # To set proxy directly into the session (Optional)
client.session.auth(...) # To set proxy auth directly into the session (Optional)
client.execute_request("mkdir", 'directory_name')
```

Webdav API
==========

Webdav API is a set of webdav actions of work with cloud storage. This set includes the following actions:
`check`, `free`, `info`, `list`, `mkdir`, `clean`, `copy`, `move`, `download`, `upload`, `publish` and `unpublish`.

**Configuring the client**

Required key is host name or IP address of the WevDAV-server with param name `webdav_hostname`.  
For authentication in WebDAV server use `webdav_login`, `webdav_password`.  
For an anonymous login do not specify auth properties.

```python
from webdav3.client import Client

options = {
 'webdav_hostname': "https://webdav.server.ru",
 'webdav_login':    "login",
 'webdav_password': "password"
}
client = Client(options)
```

If your server does not support `HEAD` method or there are other reasons to override default WebDAV methods for actions use a dictionary option `webdav_override_methods`. 
The key should be in the following list: `check`, `free`, `info`, `list`, `mkdir`, `clean`, `copy`, `move`, `download`, `upload`,
 `publish` and `unpublish`. The value should a string name of WebDAV method, for example `GET`.
 
```python
from webdav3.client import Client

options = {
 'webdav_hostname': "https://webdav.server.ru",
 'webdav_login':    "login",
 'webdav_password': "password",
 'webdav_override_methods': {
            'check': 'GET'
        }

}
client = Client(options)
```

For configuring a requests timeout you can use an option `webdav_timeout` with int value in seconds, by default the timeout is set to 30 seconds.

```python
from webdav3.client import Client

options = {
 'webdav_hostname': "https://webdav.server.ru",
 'webdav_login':    "login",
 'webdav_password': "password",
 'webdav_timeout': 30
}
client = Client(options)
```

When a proxy server you need to specify settings to connect through it.

```python
from webdav3.client import Client
options = {
 'webdav_hostname': "https://webdav.server.ru",
 'webdav_login':    "w_login",
 'webdav_password': "w_password", 
 'proxy_hostname':  "http://127.0.0.1:8080",
 'proxy_login':     "p_login",
 'proxy_password':  "p_password"
}
client = Client(options)
```

If you want to use the certificate path to certificate and private key is defined as follows:

```python
from webdav3.client import Client
options = {
 'webdav_hostname': "https://webdav.server.ru",
 'webdav_login':    "w_login",
 'webdav_password': "w_password",
 'cert_path':       "/etc/ssl/certs/certificate.crt",
 'key_path':        "/etc/ssl/private/certificate.key"
}
client = Client(options)
```

Or you want to limit the speed or turn on verbose mode:

```python
options = {
 ...
 'recv_speed' : 3000000,
 'send_speed' : 3000000,
 'verbose'    : True
}
client = Client(options)
```

recv_speed: rate limit data download speed in Bytes per second. Defaults to unlimited speed.  
send_speed: rate limit data upload speed in Bytes per second. Defaults to unlimited speed.  
verbose:    set verbose mode on/off. By default verbose mode is off.

Also if your server does not support `check` it is possible to disable it:

```python
options = {
 ...
 'disable_check': True
}
client = Client(options)
```

By default, checking of remote resources is enabled.

For configuring chunk size of content downloading use `chunk_size` param, by default it is `65536`

```python
options = {
 ...
 'chunk_size': 65536
}
client = Client(options)
```

**Synchronous methods**

```python
# Checking existence of the resource

client.check("dir1/file1")
client.check("dir1")
```

```python
# Get information about the resource

client.info("dir1/file1")
client.info("dir1/")
```

```python
# Check free space

free_size = client.free()
```

```python
# Get a list of resources

files1 = client.list()
files2 = client.list("dir1")
files3 = client.list("dir1", get_info=True) # returns a list of dictionaries with files details
```

```python
# Create directory

client.mkdir("dir1/dir2")
```

```python
# Delete resource

client.clean("dir1/dir2")
```

```python
# Copy resource

client.copy(remote_path_from="dir1/file1", remote_path_to="dir2/file1")
client.copy(remote_path_from="dir2", remote_path_to="dir3")
```

```python
# Move resource

client.move(remote_path_from="dir1/file1", remote_path_to="dir2/file1")
client.move(remote_path_from="dir2", remote_path_to="dir3")
```

```python
# Download a resource

client.download_sync(remote_path="dir1/file1", local_path="~/Downloads/file1")
client.download_sync(remote_path="dir1/dir2/", local_path="~/Downloads/dir2/")
```

```python
# Upload resource

client.upload_sync(remote_path="dir1/file1", local_path="~/Documents/file1")
client.upload_sync(remote_path="dir1/dir2/", local_path="~/Documents/dir2/")
```

```python
# Publish the resource

link = client.publish("dir1/file1")
link = client.publish("dir2")
```

```python
# Unpublish resource

client.unpublish("dir1/file1")
client.unpublish("dir2")
```

```python
# Exception handling

from webdav3.client import WebDavException
try:
...
except WebDavException as exception:
...
```

```python
# Get the missing files

client.pull(remote_directory='dir1', local_directory='~/Documents/dir1')
```

```python
# Send missing files

client.push(remote_directory='dir1', local_directory='~/Documents/dir1')
```

**Asynchronous methods**

```python
# Load resource

kwargs = {
 'remote_path': "dir1/file1",
 'local_path':  "~/Downloads/file1",
 'callback':    callback
}
client.download_async(**kwargs)

kwargs = {
 'remote_path': "dir1/dir2/",
 'local_path':  "~/Downloads/dir2/",
 'callback':    callback
}
client.download_async(**kwargs)
```

```python
# Unload resource

kwargs = {
 'remote_path': "dir1/file1",
 'local_path':  "~/Downloads/file1",
 'callback':    callback
}
client.upload_async(**kwargs)

kwargs = {
 'remote_path': "dir1/dir2/",
 'local_path':  "~/Downloads/dir2/",
 'callback':    callback
}
client.upload_async(**kwargs)
```

Resource API
============

Resource API using the concept of OOP that enables cloud-level resources.

```python
# Get a resource

res1 = client.resource("dir1/file1")
```

```python
# Work with the resource

res1.rename("file2")
res1.move("dir1/file2")
res1.copy("dir2/file1")
info = res1.info()
res1.read_from(buffer)
res1.read(local_path="~/Documents/file1")
res1.read_async(local_path="~/Documents/file1", callback)
res1.write_to(buffer)
res1.write(local_path="~/Downloads/file1")
res1.write_async(local_path="~/Downloads/file1", callback)
```

# For Contributors

### Prepare development environment
1. Install docker on your development machine
1. Start WebDAV server for testing by following commands from the project's root folder or change path to `conf` dir in second command to correct:
```shell script
docker pull bytemark/webdav
docker run -d --name webdav -e AUTH_TYPE=Basic -e USERNAME=alice -e PASSWORD=secret1234 -v conf:/usr/local/apache2/conf -p 8585:80 bytemark/webdav
``` 

### Code convention

Please check your code according PEP8 Style guides.

### Run tests
1. Check that webdav container is started on your local machine
1. Execute following command in the project's root folder:
```shell script
python -m unittest discover -s tests
```

### Prepare a Pull Request

Please use this check list before creating PR:
1. You code should be formatted according PEP8
1. All tests should successfully pass
1. Your changes shouldn't change previous default behaviour, exclude defects
1. All changes are covered by tests
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ezhov-evgeny/webdav-client-python-3",
    "name": "webdavclient3",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "webdav,client,python,module,library,packet,Yandex.Disk,Dropbox,Google Disk,Box,4shared",
    "author": "Evgeny Ezhov",
    "author_email": "ezhov.evgeny@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/be/40/dbb96e8196b32881b21fc88784caf9cabd60749d60807b1e3ffa76ca5e48/webdavclient3-3.14.6.tar.gz",
    "platform": "",
    "description": "Python WebDAV Client 3\n=========\n[![Build Status](https://travis-ci.com/ezhov-evgeny/webdav-client-python-3.svg?branch=develop)](https://travis-ci.com/ezhov-evgeny/webdav-client-python-3)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ezhov-evgeny_webdav-client-python-3&metric=alert_status)](https://sonarcloud.io/dashboard?id=ezhov-evgeny_webdav-client-python-3)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ezhov-evgeny_webdav-client-python-3&metric=coverage)](https://sonarcloud.io/dashboard?id=ezhov-evgeny_webdav-client-python-3)\n[![PyPI](https://img.shields.io/pypi/v/webdavclient3)](https://pypi.org/project/webdavclient3/) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/webdavclient3)  \n\nPackage webdavclient3 based on https://github.com/designerror/webdav-client-python but uses `requests` instead of `PyCURL`.\nIt provides easy way to work with WebDAV-servers.\n\nInstallation\n------------\n```bash\n$ pip install webdavclient3\n```\n\nSample Usage\n------------\n```python\nfrom webdav3.client import Client\noptions = {\n 'webdav_hostname': \"https://webdav.server.ru\",\n 'webdav_login':    \"login\",\n 'webdav_password': \"password\"\n}\nclient = Client(options)\nclient.verify = False # To not check SSL certificates (Default = True)\nclient.session.proxies(...) # To set proxy directly into the session (Optional)\nclient.session.auth(...) # To set proxy auth directly into the session (Optional)\nclient.execute_request(\"mkdir\", 'directory_name')\n```\n\nWebdav API\n==========\n\nWebdav API is a set of webdav actions of work with cloud storage. This set includes the following actions:\n`check`, `free`, `info`, `list`, `mkdir`, `clean`, `copy`, `move`, `download`, `upload`, `publish` and `unpublish`.\n\n**Configuring the client**\n\nRequired key is host name or IP address of the WevDAV-server with param name `webdav_hostname`.  \nFor authentication in WebDAV server use `webdav_login`, `webdav_password`.  \nFor an anonymous login do not specify auth properties.\n\n```python\nfrom webdav3.client import Client\n\noptions = {\n 'webdav_hostname': \"https://webdav.server.ru\",\n 'webdav_login':    \"login\",\n 'webdav_password': \"password\"\n}\nclient = Client(options)\n```\n\nIf your server does not support `HEAD` method or there are other reasons to override default WebDAV methods for actions use a dictionary option `webdav_override_methods`. \nThe key should be in the following list: `check`, `free`, `info`, `list`, `mkdir`, `clean`, `copy`, `move`, `download`, `upload`,\n `publish` and `unpublish`. The value should a string name of WebDAV method, for example `GET`.\n \n```python\nfrom webdav3.client import Client\n\noptions = {\n 'webdav_hostname': \"https://webdav.server.ru\",\n 'webdav_login':    \"login\",\n 'webdav_password': \"password\",\n 'webdav_override_methods': {\n            'check': 'GET'\n        }\n\n}\nclient = Client(options)\n```\n\nFor configuring a requests timeout you can use an option `webdav_timeout` with int value in seconds, by default the timeout is set to 30 seconds.\n\n```python\nfrom webdav3.client import Client\n\noptions = {\n 'webdav_hostname': \"https://webdav.server.ru\",\n 'webdav_login':    \"login\",\n 'webdav_password': \"password\",\n 'webdav_timeout': 30\n}\nclient = Client(options)\n```\n\nWhen a proxy server you need to specify settings to connect through it.\n\n```python\nfrom webdav3.client import Client\noptions = {\n 'webdav_hostname': \"https://webdav.server.ru\",\n 'webdav_login':    \"w_login\",\n 'webdav_password': \"w_password\", \n 'proxy_hostname':  \"http://127.0.0.1:8080\",\n 'proxy_login':     \"p_login\",\n 'proxy_password':  \"p_password\"\n}\nclient = Client(options)\n```\n\nIf you want to use the certificate path to certificate and private key is defined as follows:\n\n```python\nfrom webdav3.client import Client\noptions = {\n 'webdav_hostname': \"https://webdav.server.ru\",\n 'webdav_login':    \"w_login\",\n 'webdav_password': \"w_password\",\n 'cert_path':       \"/etc/ssl/certs/certificate.crt\",\n 'key_path':        \"/etc/ssl/private/certificate.key\"\n}\nclient = Client(options)\n```\n\nOr you want to limit the speed or turn on verbose mode:\n\n```python\noptions = {\n ...\n 'recv_speed' : 3000000,\n 'send_speed' : 3000000,\n 'verbose'    : True\n}\nclient = Client(options)\n```\n\nrecv_speed: rate limit data download speed in Bytes per second. Defaults to unlimited speed.  \nsend_speed: rate limit data upload speed in Bytes per second. Defaults to unlimited speed.  \nverbose:    set verbose mode on/off. By default verbose mode is off.\n\nAlso if your server does not support `check` it is possible to disable it:\n\n```python\noptions = {\n ...\n 'disable_check': True\n}\nclient = Client(options)\n```\n\nBy default, checking of remote resources is enabled.\n\nFor configuring chunk size of content downloading use `chunk_size` param, by default it is `65536`\n\n```python\noptions = {\n ...\n 'chunk_size': 65536\n}\nclient = Client(options)\n```\n\n**Synchronous methods**\n\n```python\n# Checking existence of the resource\n\nclient.check(\"dir1/file1\")\nclient.check(\"dir1\")\n```\n\n```python\n# Get information about the resource\n\nclient.info(\"dir1/file1\")\nclient.info(\"dir1/\")\n```\n\n```python\n# Check free space\n\nfree_size = client.free()\n```\n\n```python\n# Get a list of resources\n\nfiles1 = client.list()\nfiles2 = client.list(\"dir1\")\nfiles3 = client.list(\"dir1\", get_info=True) # returns a list of dictionaries with files details\n```\n\n```python\n# Create directory\n\nclient.mkdir(\"dir1/dir2\")\n```\n\n```python\n# Delete resource\n\nclient.clean(\"dir1/dir2\")\n```\n\n```python\n# Copy resource\n\nclient.copy(remote_path_from=\"dir1/file1\", remote_path_to=\"dir2/file1\")\nclient.copy(remote_path_from=\"dir2\", remote_path_to=\"dir3\")\n```\n\n```python\n# Move resource\n\nclient.move(remote_path_from=\"dir1/file1\", remote_path_to=\"dir2/file1\")\nclient.move(remote_path_from=\"dir2\", remote_path_to=\"dir3\")\n```\n\n```python\n# Download a resource\n\nclient.download_sync(remote_path=\"dir1/file1\", local_path=\"~/Downloads/file1\")\nclient.download_sync(remote_path=\"dir1/dir2/\", local_path=\"~/Downloads/dir2/\")\n```\n\n```python\n# Upload resource\n\nclient.upload_sync(remote_path=\"dir1/file1\", local_path=\"~/Documents/file1\")\nclient.upload_sync(remote_path=\"dir1/dir2/\", local_path=\"~/Documents/dir2/\")\n```\n\n```python\n# Publish the resource\n\nlink = client.publish(\"dir1/file1\")\nlink = client.publish(\"dir2\")\n```\n\n```python\n# Unpublish resource\n\nclient.unpublish(\"dir1/file1\")\nclient.unpublish(\"dir2\")\n```\n\n```python\n# Exception handling\n\nfrom webdav3.client import WebDavException\ntry:\n...\nexcept WebDavException as exception:\n...\n```\n\n```python\n# Get the missing files\n\nclient.pull(remote_directory='dir1', local_directory='~/Documents/dir1')\n```\n\n```python\n# Send missing files\n\nclient.push(remote_directory='dir1', local_directory='~/Documents/dir1')\n```\n\n**Asynchronous methods**\n\n```python\n# Load resource\n\nkwargs = {\n 'remote_path': \"dir1/file1\",\n 'local_path':  \"~/Downloads/file1\",\n 'callback':    callback\n}\nclient.download_async(**kwargs)\n\nkwargs = {\n 'remote_path': \"dir1/dir2/\",\n 'local_path':  \"~/Downloads/dir2/\",\n 'callback':    callback\n}\nclient.download_async(**kwargs)\n```\n\n```python\n# Unload resource\n\nkwargs = {\n 'remote_path': \"dir1/file1\",\n 'local_path':  \"~/Downloads/file1\",\n 'callback':    callback\n}\nclient.upload_async(**kwargs)\n\nkwargs = {\n 'remote_path': \"dir1/dir2/\",\n 'local_path':  \"~/Downloads/dir2/\",\n 'callback':    callback\n}\nclient.upload_async(**kwargs)\n```\n\nResource API\n============\n\nResource API using the concept of OOP that enables cloud-level resources.\n\n```python\n# Get a resource\n\nres1 = client.resource(\"dir1/file1\")\n```\n\n```python\n# Work with the resource\n\nres1.rename(\"file2\")\nres1.move(\"dir1/file2\")\nres1.copy(\"dir2/file1\")\ninfo = res1.info()\nres1.read_from(buffer)\nres1.read(local_path=\"~/Documents/file1\")\nres1.read_async(local_path=\"~/Documents/file1\", callback)\nres1.write_to(buffer)\nres1.write(local_path=\"~/Downloads/file1\")\nres1.write_async(local_path=\"~/Downloads/file1\", callback)\n```\n\n# For Contributors\n\n### Prepare development environment\n1. Install docker on your development machine\n1. Start WebDAV server for testing by following commands from the project's root folder or change path to `conf` dir in second command to correct:\n```shell script\ndocker pull bytemark/webdav\ndocker run -d --name webdav -e AUTH_TYPE=Basic -e USERNAME=alice -e PASSWORD=secret1234 -v conf:/usr/local/apache2/conf -p 8585:80 bytemark/webdav\n``` \n\n### Code convention\n\nPlease check your code according PEP8 Style guides.\n\n### Run tests\n1. Check that webdav container is started on your local machine\n1. Execute following command in the project's root folder:\n```shell script\npython -m unittest discover -s tests\n```\n\n### Prepare a Pull Request\n\nPlease use this check list before creating PR:\n1. You code should be formatted according PEP8\n1. All tests should successfully pass\n1. Your changes shouldn't change previous default behaviour, exclude defects\n1. All changes are covered by tests",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "WebDAV client, based on original package https://github.com/designerror/webdav-client-python but uses requests instead of PyCURL",
    "version": "3.14.6",
    "project_urls": {
        "Homepage": "https://github.com/ezhov-evgeny/webdav-client-python-3"
    },
    "split_keywords": [
        "webdav",
        "client",
        "python",
        "module",
        "library",
        "packet",
        "yandex.disk",
        "dropbox",
        "google disk",
        "box",
        "4shared"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "be40dbb96e8196b32881b21fc88784caf9cabd60749d60807b1e3ffa76ca5e48",
                "md5": "64b2bb3cb51509430e50126ff5dbe857",
                "sha256": "bcd22586bb0d58abc26ca56054fd04228e704bd36073c3080f4597c1556c880d"
            },
            "downloads": -1,
            "filename": "webdavclient3-3.14.6.tar.gz",
            "has_sig": false,
            "md5_digest": "64b2bb3cb51509430e50126ff5dbe857",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 23493,
            "upload_time": "2021-08-12T18:48:25",
            "upload_time_iso_8601": "2021-08-12T18:48:25.879104Z",
            "url": "https://files.pythonhosted.org/packages/be/40/dbb96e8196b32881b21fc88784caf9cabd60749d60807b1e3ffa76ca5e48/webdavclient3-3.14.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-08-12 18:48:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ezhov-evgeny",
    "github_project": "webdav-client-python-3",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "lcname": "webdavclient3"
}
        
Elapsed time: 0.64808s