Skip to main content

Python client library for ownCloud

Project description

https://travis-ci.org/owncloud/pyocclient.svg?branch=master

This pure python library makes it possible to connect to an ownCloud instance and perform file, share and attribute operations.

Please note that this is not a sync client implementation but a library that provides functions to abstract away HTTP calls for various ownCloud APIs.

See the ownCloud homepage for more information about ownCloud.

Features

Supports connecting to ownCloud 8.2, 9.0, 9.1 and newer.

General information

  • retrieve information about ownCloud instance (e.g. version, host, URL, etc.)

Accessing files

  • basic file operations like getting a directory listing, file upload/download, directory creation, etc

  • read/write file contents from strings

  • upload with chunking and mtime keeping

  • upload whole directories

  • directory download as zip

  • access files from public links

  • upload files to files drop link target

Sharing (OCS Share API)

  • share a file/directory via public link

  • share a file/directory with another user or group

  • unshare a file/directory

  • check if a file/directory is already shared

  • get information about a shared resource

  • update properties of a known share

Apps (OCS Provisioning API)

  • enable/disable apps

  • retrieve list of enabled apps

Users (OCS Provisioning API)

  • create/delete users

  • create/delete groups

  • add/remove user from groups

App data

  • store app data as key/values using the privatedata OCS API

Requirements

  • Python >= 2.7 or Python >= 3.5

  • requests module (for making HTTP requests)

Installation

Automatic installation with pip:

$ pip install pyocclient

Manual installation of development version with git:

$ pip install requests
$ git clone https://github.com/owncloud/pyocclient.git
$ cd pyocclient
$ python setup.py install

Usage

Example for uploading a file then sharing with link:

import owncloud

oc = owncloud.Client('http://domain.tld/owncloud')

oc.login('user', 'password')

oc.mkdir('testdir')

oc.put_file('testdir/remotefile.txt', 'localfile.txt')

link_info = oc.share_file_with_link('testdir/remotefile.txt')

print "Here is your link: " + link_info.get_link()

Example for uploading a file to a public shared folder:

import owncloud

public_link = 'http://domain.tld/owncloud/A1B2C3D4'

oc = owncloud.Client.from_public_link(public_link)
oc.drop_file('myfile.zip')

Example for downloading a file from a public shared folder with password:

import owncloud

public_link = 'http://domain.tld/owncloud/A1B2C3D4'
folder_password = 'secret'

oc = owncloud.Client.from_public_link(public_link, password=folder_password)
oc.get_file('/sharedfile.zip', 'download/destination/sharedfile.zip')

Running the unit tests

To run the unit tests, create a config file called “owncloud/test/config.py”. There is a config file example called “owncloud/test/config.py.sample”. All the information required is in that file. It should point to a running ownCloud instance to test against.

You might also need to install the unittest-data-provider package:

$ pip install unittest-data-provider

Then run the script “runtests.sh”:

$ ./runtests.sh

Building the documentation

To build the documentation, you will need to install Sphinx and docutil. Then run the following commands:

$ sphinx-apidoc -e -f -o docs/source owncloud/ owncloud/test
$ cd docs
$ make html

You can then find the documentation inside of “doc/build/html”.

Contributors

Contributors

Changelog

0.6

  • Added support to query arbitrary properties with file info and file listing [NikosChondros]

  • Added support for file operations within a public link [mrwunderbar666]

0.5

  • Added “name” attribute for public links [PVince81]

  • Fixed deprecation warnings [Tilman Lüttje] [PVince81]

  • Added support sharing with federated users [remjg]

  • Fixed setup script for utf-8 paths [amicitas]

  • Fixed file mtime parsing issue [viraj96]

  • Add support for the server’s DAV v2 endpoint [PVince81]

  • Remove support for ownCloud 8.1, 9.0 and 9.1 which are EOL [PVince81]

0.4

  • Some code cleanup removing needless if statements [jamescooke]

  • Remove old session_mode [PVince81]

  • Set Depth to 0 in file_info call [PVince81]

  • Make subclassing of Client event easier with protected methods [bobatsar]

0.3

  • Make subclassing of Client easier [bobatsar]

  • Add Depth param for recursive listing [bobatsar]

  • Add shared_with_me parameter to get_shares [bobatsar]

  • Link variable is now called url inside of shareinfo [SergioBertolinSG]

  • Python3 support [ethifus] [Blizzz]

0.2

  • Webdav COPY support [individual-it]

  • Added API for federated sharing [nickvergessen]

  • Fix login issue in case of failed login [individual-it]

  • Added function to get capabilities [SergioBertolinSG]

  • Added subadmin APIs for provisioning API [svigneux]

  • Tests for provisioning API [individual-it]

  • Added provisioning API functions [jennifer]

  • Code cleanup / PEP8 formatting [jennifer]

  • Added status check function [soalhn]

  • Added share API functions [soalhn] [SergioBertolinSG]

  • Travis integration [Gomez]

  • Added session handling workaround for OC 5 [PVince81]

  • Fixed many issues related to unicode path names [PVince81]

  • Client now works properly on Windows [PVince81]

0.1

  • Make python egg [PVince81]

  • Initial release [PVince81]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyocclient-0.6.tar.gz (29.0 kB view details)

Uploaded Source

Built Distributions

pyocclient-0.6-py3.8.egg (59.1 kB view details)

Uploaded Egg

pyocclient-0.6-py2.7.egg (58.7 kB view details)

Uploaded Egg

File details

Details for the file pyocclient-0.6.tar.gz.

File metadata

  • Download URL: pyocclient-0.6.tar.gz
  • Upload date:
  • Size: 29.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for pyocclient-0.6.tar.gz
Algorithm Hash digest
SHA256 a33ddcbbd2ec22d9bc7d76b71dd77896c557221153d1428759780b5fb8fe8fa3
MD5 b3ee49f25c5d0ef4031c2fd617769b44
BLAKE2b-256 1fcec60f248822f4a4cc922a2766714e884a2eced5d8fc06a26ffe875ae1de09

See more details on using hashes here.

File details

Details for the file pyocclient-0.6-py3.8.egg.

File metadata

  • Download URL: pyocclient-0.6-py3.8.egg
  • Upload date:
  • Size: 59.1 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.8

File hashes

Hashes for pyocclient-0.6-py3.8.egg
Algorithm Hash digest
SHA256 a02151c0435851ca80582731da52c07f23c70b9c2d185c5f87f6e93c5db63dd3
MD5 3b35aa0da1b45ab4b3e988f04616085c
BLAKE2b-256 22194edeb2fc7460052127c3621c2461c0deedc9181e8e9f2f5e331b4d7dc89a

See more details on using hashes here.

File details

Details for the file pyocclient-0.6-py2.7.egg.

File metadata

  • Download URL: pyocclient-0.6-py2.7.egg
  • Upload date:
  • Size: 58.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for pyocclient-0.6-py2.7.egg
Algorithm Hash digest
SHA256 b9fbe49ed6bf7594dbb3dc0dc477c92204dbd7c0b9495166421e74a96b05735c
MD5 6a423bab1125c1ed7b00030a9a6b46e0
BLAKE2b-256 2ea5039870a824dc68c7698d3fcdb00f3d077fea80bc8051476b83efb3bd1bdc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page