Seite 1 von 1

Python + WebDAV zu Owncloud?

Verfasst: Mittwoch 10. Juli 2013, 21:16
von djangofish
Hallo,

ich wollte einen Script schreiben was meine Podcast in meine Owncloud archiviert. Leider geht es nicht so recht.

Folgendes Script:

Code: Alles auswählen


import easywebdav


ewdClient = easywebdav.connect('http://xxx.yyy.zzz.aaa/owncloud/remote.php/webdav/', 'user', 'pw')
print ewdClient.cwd
ewdClient.mkdir('some_dir')
Produziert diesen Fehler:

Code: Alles auswählen


Traceback (most recent call last):
  File "/home/klofisch/workspace/Schnipselsammlung/webdav/tinydav.py", line 7, in <module>
    ewdClient.mkdir('/some_dir')
  File "/usr/local/lib/python2.7/dist-packages/easywebdav/client.py", line 100, in mkdir
    self._send('MKCOL', path, expected_codes)
  File "/usr/local/lib/python2.7/dist-packages/easywebdav/client.py", line 77, in _send
    response = self.session.request(method, url, allow_redirects=False, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 324, in request
    prep = req.prepare()
  File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 222, in prepare
    p.prepare_url(self.url, self.params)
  File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 288, in prepare_url
    scheme, auth, host, port, path, query, fragment = parse_url(url)
  File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util.py", line 156, in parse_url
    raise LocationParseError("Failed to parse: %s" % url)
requests.packages.urllib3.exceptions.LocationParseError: Failed to parse: Failed to parse: http:

Ich sehe eigentlich keinen Grund, warum es dazu kommt. Per Browser geht alles.

Habt ihr nen Tip?


Danke
Peter

Re: Python + WebDAV zu Owncloud?

Verfasst: Mittwoch 10. Juli 2013, 21:37
von BlackJack
@djangofish: Lass doch mal das 'http://' weg. Die Beispiele haben das doch auch nicht.

Re: Python + WebDAV zu Owncloud?

Verfasst: Mittwoch 10. Juli 2013, 21:57
von djangofish
Hab ich auch schon bemerkt.,..bringt mich auch nur ein Schrittchen weiter

Code: Alles auswählen

print ewdClient.baseurl
ergibt folgendes:

Code: Alles auswählen

http://xxx.yyy.zzz.aaa/owncloud/remote.php/webdav/:80
Damit ist der Link wohl eher nicht konform. Wenn ich das probeweise in meinen Browser kopiere, kommt

Code: Alles auswählen

<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" slick-uniqueid="3">
<SCRIPT/>
<s:exception>Sabre_DAV_Exception_NotFound</s:exception>
<s:message>File with name /:80 could not be located</s:message>
<s:sabredav-version>1.7.6</s:sabredav-version>
</d:error>

Re: Python + WebDAV zu Owncloud?

Verfasst: Mittwoch 10. Juli 2013, 22:06
von BlackJack
@djangofish: Ja und? Was *Du* mit den Attributen im Browser anstellst, ist doch eigentlich egal. `baseurl` klingt ja nicht gerade danach, dass das schon eine vollständige Angabe ist. Die Klasse wird das wohl noch um weitere Zeichen ergänzen wenn man die Methoden verwendet.

Re: Python + WebDAV zu Owncloud?

Verfasst: Mittwoch 10. Juli 2013, 22:59
von Sirius3
@djangofish: der Quellcode ist wirklich nicht schwer zu verstehen. Der erste Parameter muss der »host« sein. Mit einer kompletten URL kommt easywebdav nicht klar.

Was ihn aber nicht stört, ist wenn Du »baseurl« danach auf Deine komplette Url setzt.