Skip to main content

A Python API client for BitTorrent Sync

Project description

____ ______ _____ __ __ ____ __ ____ __ __
| \ | |/ ___/| | || \ / ] | \| | |
| o )| ( \_ | | || _ | / / | o ) | |
| ||_| |_|\__ || ~ || | |/ / | _/| ~ |
| O | | | / \ ||___, || | / \_ __ | | |___, |
| | | | \ || || | \ || || | | |
|_____| |__| \___||____/ |__|__|\____||__||__| |____/


[![Build Status](https://travis-ci.org/kevinjqiu/btsync.py.png?branch=master)](https://travis-ci.org/kevinjqiu/btsync.py)
[![Coverage Status](https://coveralls.io/repos/kevinjqiu/btsync.py/badge.png?branch=master)](https://coveralls.io/r/kevinjqiu/btsync.py?branch=master)

A Python API client for BitTorrent Sync


Installation
============

Install from [PyPI](https://pypi.python.org):

pip install btsync.py

Or Install from source:

git clone git@github.com:kevinjqiu/btsync.py.git
cd btsync.py
pip install -r requirements.txt
python setup.py install

Examples
========

You need to first download [btsync](http://labs.bittorrent.com/experiments/sync/get-started.html) for your platform. Once it's downloaded, extract it somewhere and generate a sample config file:

cd /path/to/btsync
./btsync --dump-sample-config > config

Change the default config if you wish. The pieces of config you need for the client to connect are:
- host
- port (listening port)
- username
- password

Run `btsync` with the config:

./btsync --config config

With btsync running, now you can connect to it using this library:

Creating a client:

In [1]: import btsync

In [2]: client = btsync.Client(
...: host='127.0.0.1',
...: port='1106',
...: username='admin',
...: password='password')

Listing sync folders:

In [3]: client.sync_folders
Out[3]:
[{u'iswritable': 1,
u'name': u'/home/foo/bar',
u'peers': [{u'direct': 1,
u'name': u'rpi',
u'status': u'Synced on 10/08/13 11:21:30'}],
u'readonlysecret': u'--------------------------------',
u'secret': u'--------------------------------',
u'size': u'353.9 MB in 256 files'},
{u'iswritable': 1,
u'name': u'/tmp',
u'peers': [],
u'readonlysecret': u'--------------------------------',
u'secret': u'--------------------------------',
u'size': u'56.9 kB in 14 files'}]

Generate a secret for adding a sync folder:

In [7]: secret = client.generate_secret()

In [8]: secret
Out[8]:
{u'rosecret': u'--------------------------------',
u'secret': u'--------------------------------'}

Add a sync folder:

In [10]: client.add_sync_folder('/tmp', secret['rosecret'])

In [11]: client.sync_folders[1]
Out[11]:
{u'iswritable': 0,
u'name': u'/tmp',
u'peers': [],
u'secret': u'--------------------------------',
u'size': u'0 B in 0 files'}


Development
===========

First, you need to setup a virtualenv, as it segregates local dependencies from the system libraries nicely:

$ virtualenv btsync.py-env

Activate the virtual environment:

$ cd btsync.py-env
$ . btsync.py-env/bin/activate

Clone this repo somewhere, e.g., `$HOME/src/btsync.py`:

$ git clone git@github.com:kevinjqiu/btsync.py.git
$ cd btsync.py

Install dev dependencies:

$ pip install -r requirements-dev.txt

Run tests:

$ fab test

You can also generate the coverage report:

$ fab coverage

To run integration tests, you need to have `btsync` executable on your `$PATH`, or change `test/integration/test_integration.py` to point it to your btsync path, then invoke:

$ fab test_integration

To run coverage for integration tests:

$ fab coverage:integration


License
=======

See [license.txt](license.txt)

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

btsync.py-0.9.2.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

btsync.py-0.9.2-py2.7.egg (6.8 kB view details)

Uploaded Egg

File details

Details for the file btsync.py-0.9.2.tar.gz.

File metadata

  • Download URL: btsync.py-0.9.2.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for btsync.py-0.9.2.tar.gz
Algorithm Hash digest
SHA256 7518392ce15c2c57afa079980452f3d08e0f1cd5a00e5a114e9feb8078ad38a1
MD5 f01cace1925478efa2c3ff8527cc114f
BLAKE2b-256 389ea9061bb515614ffb45d2644aa683f39530f943c63a4e04915b655804b526

See more details on using hashes here.

File details

Details for the file btsync.py-0.9.2-py2.7.egg.

File metadata

  • Download URL: btsync.py-0.9.2-py2.7.egg
  • Upload date:
  • Size: 6.8 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for btsync.py-0.9.2-py2.7.egg
Algorithm Hash digest
SHA256 eab5e93878cd23d0bf888b78d1224f45f1087203a45d4db35de9043ac21168dc
MD5 1200d494a8aef3897752481a26d1bc8a
BLAKE2b-256 62562ff91fac8ff379082d62dd992842414379f3a4ff471b39774e86c1dba2a8

See more details on using hashes here.

Supported by

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