storj-thirdparty / uplink-python

Python bindings for libuplink
https://storj.io
Apache License 2.0
19 stars 10 forks source link
bindings python

uplink-python binding

Codacy Badge

Developed using v1.2.2 storj/uplink-c

API documentation and tutorial

Initial Set-up (Important)

NOTE: for Golang

Make sure your PATH includes the $GOPATH/bin directory, so that your commands can be easily used Refer: Install the Go Tools:

export PATH=$PATH:$GOPATH/bin

Depending on your operating system, you will need to install:

On Unix

On macOS

On Windows

Please ensure you have Python 3.x and pip installed on your system. If you have Python version 3.4 or later, pip is included by default. uplink-python does not support Python 2.x.

$ python get-pip.py

Option 1

Install uplink-python python package with --no-cache-dir tag if re-installing or upgrading from the previous version, otherwise, the tag can be ignored (using Terminal/Powershell/CMD as Administrator):

$ pip install --no-cache-dir uplink-python

Note: If Administrator privilege is not granted to the terminal/cmd, the libuplinkc.so build process may fail.

Option 2

Follow these steps to set-up binding manually or if libuplinkc.so fails to build using Option 1.

Project Set-up

To include uplink in your project, import the library, by using the following command:

from uplink_python.uplink import Uplink

Create an object of Uplink class to access all the functions of the library. Please refer to the sample hello_storj.py file, for example.

variable_name = Uplink()

To use various parameters such as ListBucketsOptions, ListObjectsOptions, Permissions, etc you would require to import them first from module_classes i.e. uplink_python.module_classes.

from uplink_python.module_classes import DownloadOptions, Permission

To use various user-defined Storj Exceptions such as InternalError, BucketNotFoundError, etc you would require to import them first from errors i.e. uplink_python.errors.

from uplink_python.errors import InternalError, BucketNotFoundError

Sample Hello Storj!

File hello_storj.py can be found in the folder where the Python package was installed.

The sample hello_storj.py code calls the uplink.py file and imports the Uplink binding class to do the following:

Run Unit Test Cases on Local

Directory with unit test cases test can be found in the uplink-python repository.

To run the test cases on a local system, you need to perform the following steps:

Documentation

For more information on function definations and diagrams, check out the Detail or jump to: