使用pyocclient错误,ownCloud的Python客户端库

时间:2018-10-05 13:35:25

标签: python curl owncloud

我在使用pyocclient(ownCloud的Python客户端库)将文件发送到目录时遇到麻烦。错误是:

>>> oc.put_file('testdir/remotefile.txt', 'localfile.txt')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/owncloud/owncloud.py", line 507, in put_file
**kwargs
  File "/usr/local/lib/python3.6/dist-packages/owncloud/owncloud.py", line 616, in _put_file_chunked
headers=headers
  File "/usr/local/lib/python3.6/dist-packages/owncloud/owncloud.py", line 1679, in _make_dav_request
raise HTTPResponseError(res)
owncloud.owncloud.HTTPResponseError: HTTP error: 500

注意:put_file()失败,错误500,但是localfile.txt实际上已发送到目标文件夹!

另一方面,它可以正常使用curl命令:

curl -H 'Authorization: Basic Y...2' -T localfile.txt http://nextcloud-mshe.univ-fcomte.fr/remote.php/dav/files/admin/testdir/remotefile.txt

我尝试使用python2和python3。 owncloud服务器:9.1.8 pyocclient:0.4

在owncloud服务器日志中,我们可以阅读以下几行:     {“ reqId”:“ Si0R01H5S7hbMjn6I9 / 0”,“ remoteAddr”:“ 172.20.74.124”,“ app”:“ webdav”,“ message”:“ Exception:{\” Message \“:\”执行时发生异常'UPDATE \\“ oc_filecache \\” SET \\“ mtime \\” = GREATEST(\\“ mtime \\”,?),\\“ etag \\” =? WHERE(\\ “存储\\”=α)和(\\ “path_hash \\” IN( 'd41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1', 'a02c96afea6d850f30883ffeb9d76563'))”使用参数[\\ “1537967228.3743448 \\”,\\ “ 5bb1d53254ead \\”,1]:\ n \ nSQLSTATE [22P02]:无效的文本表示形式:7 ERREUR:语法错误,\ u00ab 1537967228.3743448 \ u00bb \“,\” Exception \“:\ “ Doctrine \\ DBAL \\ Exception \\ DriverException \”,\“代码\”:0,\“ Trace \”:\“#0 \ / var \ / www \ / owncloud \ / 3rdparty \ / doctrine \ / dbal \ / lib \ / Doctrine \ / DBAL \ /DBALException.php(116):教义\\ DBAL \\ Driver \\ AbstractPostgreSQLDriver-> convertException('Exception oc ...',Object(Doctrine \\ DBAL \\ Driver \\ PDOException))\ n#1 \ / var \ / www \ / owncloud \ / 3rdparty \ / doctrine \ / dbal \ / lib \ / Doctrine \ / DBAL \ /Connection.php(996):Doctrine \\ DBAL \ \ DBALException :: driverExceptionDuringQuery(Object(Doctrine \\ DBAL \\ Driver \\ PDOPgSql \\ Driver),Object(Doctrine \\ DBAL \\ Driver \\ PDOException),'UPDATE \\“ oc_file ...',Array) \ n#2 \ / var \ / www \ / owncloud \ / lib \ / private \ / DB \ /Connection.php(209):原则\\ DBAL \\ Connection-> executeUpdate('UPDATE \\“ oc_file ...',Array,Array)\ n#3 \ / var \ / www \ / owncloud \ / 3rdparty \ / doctrine \ / dbal \ / lib \ / Doctrine \ / DBAL \ / Query \ /QueryBuilder.php(208):OC \\ DB \\ Connection-> executeUpdate('UPDATE`* PREFIX ... ',Array,Array)\ n#4 \ / var \ / www \ / owncloud \ / lib \ / private \ / DB \ / QueryBuilder \ /QueryBuilder.php(141):教义\\ DBAL \\ Query \\ QueryBuilder -> execute()\ n#5 \ / var \ / www \ / owncloud \ / lib \ / private \ / Files \ / Cache \ /Propagator.php(87):OC \\ DB \\ QueryBuilder \\ QueryBuilder- > execute()\ n#6 \ / var \ / www \ / owncloud \ / lib \ / private \ / Files \ / Cache \ /HomePropagator.php(48):OC \\ Files \\ Cache \\ Propagator-> multicastChange('files \ / testdir \ / r ...','1537967228.3743 ...',0)\ n#7 \ / var \ / www \ / owncloud \ / lib \ / private \ / Files \ / Cache \ /Updater.php(137):OC \\ Files \\ Cache \\ HomePropagator-> propagateChange('files \ / testdir \ / r ...','1537967228.3743 ...',0)\ n#8 \ / var \ / www \ / owncloud \ / lib \ / private \ / Files \ /View.php(314):OC \\ Files \\ Cache \\ Updater-> update('files \ / testdir \ / r ... ','1537967 228.3743 ...')\ n#9 \ / var \ / www \ / owncloud \ / lib \ / private \ / Files \ /View.php(1141):OC \\ Files \\ View-> writeUpdate(Object( OCA \\ Files_Trashbin \\ Storage),'files \ / testdir \ / r ...','1537967228.3743 ...')\ n#10 \ / var \ / www \ / owncloud \ / lib \ / private \ / Files \ /View.php(551):OC \\ Files \\ View-> basicOperation('touch','\ / testdir \ / remote ...',Array,'1537967228.3743 ...')\ n#11 \ / var \ / www \ / owncloud \ / apps \ / dav \ / lib \ / Connector \ / Sabre \ /File.php(208):OC \\ Files \\ View-> touch('\ / testdir \ /远程...'','1537967228.3743 ...')\ n#12 \ / var \ / www \ / owncloud \ / apps \ / dav \ / lib \ / Connector \ / Sabre \ /Directory.php(136): OCA \\ DAV \\ Connector \\ Sabre \\ File-> put(资源ID#61)\ n#13 \ / var \ / www \ / owncloud \ / 3rdparty \ / sabre \ / dav \ / lib \ / DAV \ /Server.php(1036):OCA \\ DAV \\ Connector \\ Sabre \\ Directory-> createFile('remotefile.txt',资源ID#61)\ n#14 \ / var \ / www \ / owncloud \ / 3rdparty \ / sabre \ / dav \ / lib \ / DAV \ /CorePlugin.php(523):Sabre \\ DAV \\ Server-> createFile('testdir \ / remotef ...',资源ID#61, NULL)\ n#15 [内部函数]:Sabre \\ DAV \\ CorePlugin-> htt pPut(对象(Sabre \\ HTTP \\ Request),对象(Sabre \\ HTTP \\ Response))\ n#16 \ / var \ / www \ / owncloud \ / 3rdparty \ / sabre \ / event \ / lib \ /EventEmitterTrait.php(105):call_user_func_array(Array,Array)\ n#17 \ / var \ / www \ / owncloud \ / 3rdparty \ / sabre \ / dav \ / lib \ / DAV \ /Server.php(459) :Sabre \\ Event \\ EventEmitter-> emit('method:PUT',Array)\ n#18 \ / var \ / www \ / owncloud \ / 3rdparty \ / sabre \ / dav \ / lib \ / DAV \ / Server.php(248):Sabre \\ DAV \\ Server-> invokeMethod(Object(Sabre \\ HTTP \\ Request),Object(Sabre \\ HTTP \\ Response))\ n#19 \ / var \ / www \ / owncloud \ / apps \ / dav \ / appinfo \ / v1 \ /webdav.php(61):Sabre \\ DAV \\ Server-> exec()\ n#20 \ / var \ / www \ / owncloud \ /remote.php(164):require_once('\ / var \ / www \ / ownclo ...')\ n#21 {main} \“,\” File \“:\” \ / var \ / www \ /owncloud\/3rdparty\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Driver\/AbstractPostgreSQLDriver.php \“,\” Line \“:91,\” User \“:\” admin \“ }“,”级别“:4,”时间“:” 2018-10-01T08:05:06 + 00:00“,”方法“:” PUT“,” URL“:” / remote.php / webdav / testdir /remotefile.txt“,”用户“:”管理员“}

Python脚本非常简单,您只需要安装pyocclient库(pip install pyocclient)。当然,需要有一个owncloud服务器。

#!/usr/bin/python2.7
# -*-coding:Utf-8 -*
import owncloud
oc = owncloud.Client('http://your-owncloud.mydomain.org')
oc.login('admin', 'secret')
#oc.delete('testdir')
oc.mkdir('testdir')
oc.put_file('testdir/remotefile.txt', 'localfile.txt')

预先感谢您的帮助。

0 个答案:

没有答案