amnong / easywebdav

A WebDAV Client in Python
http://pypi.python.org/pypi/easywebdav/
ISC License
207 stars 113 forks source link

ls() fails on Nextcloud server #55

Open schferbe opened 6 years ago

schferbe commented 6 years ago

When I run the ls() command with a connection to a Nextcloud server parts of my stacktrace look like this:

  File "/usr/lib/python3.6/site-packages/easywebdav/client.py", line 184, in ls
    return [elem2file(elem) for elem in tree.findall('{DAV:}response')]
  File "/usr/lib/python3.6/site-packages/easywebdav/client.py", line 184, in <listcomp>
    return [elem2file(elem) for elem in tree.findall('{DAV:}response')]
  File "/usr/lib/python3.6/site-packages/easywebdav/client.py", line 40, in elem2file
    int(prop(elem, 'getcontentlength', 0)),
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

It seems as if not content length for directories is provided. I solved the issue by changing the return statement of prop in client.py to return default if child is None or child.text is None else child.text. I'll be submitting a pull request for this shortly.