Name or service not known error in EasyWebDav for Python

1k views Asked by At

I'm trying to setup a WebDAV connection using easywebdav in Python. (Using 2.7.8 for now)

import csv, easywebdav

webdav=easywebdav.connect('https://sakai.rutgers.edu/dav/restoftheurl,username="",password="")
print webdav.ls()

Though when I run this I get the following error message. My guess is that it possibly has something to do with the URL using HTTPS?

Traceback (most recent call last):
  File "/home/willkara/Development/SakaiStuff/WorkProjects/sakai-manager/file.py", line 4, in <module>
    print webdav.ls()
  File "build/bdist.linux-x86_64/egg/easywebdav/client.py", line 176, in ls
  File "build/bdist.linux-x86_64/egg/easywebdav/client.py", line 97, in _send
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 456, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 559, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 375, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='https', port=80): Max retries exceeded with url: //sakai.rutgers.edu/dav/url:80/. (Caused by <class 'socket.gaierror'>: [Errno -2] Name or service not known)
[Finished in 0.1s with exit code 1]
2

There are 2 answers

1
Martin Prikryl On BEST ANSWER

I find it strange that you combine HTTPS protocol and port 80. HTTPS uses port 443.

Though the error message "Name or service not known" would rather indicate that the hostname sakai.rutgers.edu is not recognized on your system. Try to ping the host.

0
HeMan On

I noticed that you shouldn't have http:// or https:// in the beginning of your adress, only the host name. You select protocol with protocol='https'. Also, I couln't get it to work if I added the path the url, I had to use it as argument to the operations like easywebdav.ls('/dav/restoftheurl') or easywebdav.cd('/dav/restoftheurl').