# Webdav connection

**URL:** <https://swan-community.web.cern.ch/t/webdav-connection/240>\
**Category:** Uncategorized\
**Created:** [April 28, 2020, 5:07pm UTC](https://swan-community.web.cern.ch/t/webdav-connection/240 "2020-04-28T17:07:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fchapron](https://swan-community.web.cern.ch/letter_avatar_proxy/v4/letter/f/f14d63/32.png) [@fchapron](https://swan-community.web.cern.ch/u/fchapron)\
**Post date:** [April 28, 2020, 5:07pm UTC](https://swan-community.web.cern.ch/t/webdav-connection/240/1 "2020-04-28T17:07:10Z")

</div>

Hi,  
I am a new swan user.  
I trying to copy a file from my cernbox to an IT web server using webdav3.  
It works with my local machine, but not from swan.  
The webdav connection seems to be valid, but I have access to no resource.  
Thanks for help  
Frédéric

---

<div class="post-metadata">

**Author:** ![ebocchi](https://swan-community.web.cern.ch/letter_avatar_proxy/v4/letter/e/35a633/32.png) [@ebocchi](https://swan-community.web.cern.ch/u/ebocchi)\
**Post date:** [April 29, 2020, 6:50am UTC](https://swan-community.web.cern.ch/t/webdav-connection/240/2 "2020-04-29T06:50:52Z")

</div>

Dear Frédéric,

SWAN uses CERNBox for storing notebooks and related files, the rationale being that having a single storage between these two services allows for a unified view of files and folders and for the use of advanced features (sync, sharing) for notebooks.

You should be able to copy the files you want from CERNBox via WebDAV even if they were created or modified by SWAN.  
If you need to copy such files form SWAN, I would need to better understand your workflow and the error you report (_“I have access to no resource”_) to provide support.

Kind regards,  
Enrico

---

<div class="post-metadata">

**Author:** ![fchapron](https://swan-community.web.cern.ch/letter_avatar_proxy/v4/letter/f/f14d63/32.png) [@fchapron](https://swan-community.web.cern.ch/u/fchapron)\
**Post date:** [April 30, 2020, 7:19am UTC](https://swan-community.web.cern.ch/t/webdav-connection/240/3 "2020-04-30T07:19:51Z")

</div>

Hi Enrico,

Thanks for the reply. Actually I found another way to do what I wanted using Confluence as a website.

But, here is what I was doing. I was trying to “publish” automatically a web-page I created in my Swan environment. The page is store in my CERNBox, and I want to upload it to my website (hosted by IT). That’s why I thought about webdav. Here is what I had in the code:

* * *

from webdav3.client import Client  
options = {  
‘webdav\_hostname’: “[https://dfs.cern.ch/dfs/websites/t/test-be-ics-stats](https://dfs.cern.ch/dfs/websites/t/test-be-ics-stats)”,  
‘webdav\_login’: user,  
‘webdav\_password’: password  
}

## #webdav connection client = Client(options) client.upload(“Default.htm”,“BE-ICS-TI-Gantt-Chart-statistics.htm”)

The result was:

* * *

## User: fchapron Enter password: ········ WARNING:root:Connecting to server

RemoteParentNotFound Traceback (most recent call last)  
 in   
283 #webdav connection  
284 client = Client(options)  
–\> 285 client.upload(“Default.htm”,“BE-ICS-TI-Gantt-Chart-statistics.htm”)  
286  
287 print(“End of script”)

~/.local/lib/python3.7/site-packages/webdav3/client.py in upload(self, remote\_path, local\_path, progress)  
436 self.upload\_directory(local\_path=local\_path, remote\_path=remote\_path, progress=progress)  
437 else:  
–\> 438 self.upload\_file(local\_path=local\_path, remote\_path=remote\_path)  
439  
440 def upload\_directory(self, remote\_path, local\_path, progress=None):

~/.local/lib/python3.7/site-packages/webdav3/client.py in \_wrapper(self, \*args, \*\*kw)  
63 log.debug(“Requesting %s(%s, %s)”, fn, args, kw)  
64 try:  
—\> 65 res = fn(self, \*args, \*\*kw)  
66 except requests.ConnectionError:  
67 raise NoConnection(self.webdav.hostname)

~/.local/lib/python3.7/site-packages/webdav3/client.py in upload\_file(self, remote\_path, local\_path, progress)  
487  
488 if not self.check(urn.parent()):  
–\> 489 raise RemoteParentNotFound(urn.path())  
490  
491 with open(local\_path, “rb”) as local\_file:

## RemoteParentNotFound: Remote parent for: /Default.htm not found

So, as I succeeded to fulfill my needs in a another way, I don’t want to waist your time, we can forget this issue, but if we can solve it, it might be useful in future.

Cheers,  
Frédéric

---

<div class="post-metadata">

**Author:** ![ebocchi](https://swan-community.web.cern.ch/letter_avatar_proxy/v4/letter/e/35a633/32.png) [@ebocchi](https://swan-community.web.cern.ch/u/ebocchi)\
**Post date:** [April 30, 2020, 12:31pm UTC](https://swan-community.web.cern.ch/t/webdav-connection/240/4 "2020-04-30T12:31:36Z")

</div>

Hello Frédéric,

Could you please try to set the root directory you want to write to as a separate parameters and not in the hostname?

Example with my home directory on DFS:

```python
from webdav3.client import Client

# Webdav connection
options = {
'webdav_hostname': "https://dfs.cern.ch",
'webdav_root': 'dfs/users/e/ebocchi',
'webdav_login': %%USERNAME%%,
'webdav_password': %%PASSWORD%%
}
client = Client(options)
print ("$HOME: ", client.list())

# Desktop is initially empty
print ("Desktop: ", client.list('Desktop/'))

# Create and upload a test file
with open('test.log', 'w') as fout:
    fout.write("This is a test file")
client.upload(remote_path='Desktop/test.uploaded.log', local_path='test.log')

# Desktop now contains 'test.uploaded.log'
print ("Desktop: ", client.list('Desktop/'))

```

Output of the snippet:

```auto
$HOME: ['Contacts/', 'Desktop/', 'Documents/', 'Favorites/', 'Links/', 'Public/']
Desktop: []
Desktop: ['test.uploaded.log']

```
