btsync.py
____ ______ _____ __ __ ____ __ ____ __ __ | \ | |/ ___/| | || \ / ] | \| | | | o )| ( \_ | | || _ | / / | o ) | | | ||_| |_|\__ || ~ || | |/ / | _/| ~ | | O | | | / \ ||___, || | / \_ __ | | |___, | | | | | \ || || | \ || || | | | |_____| |__| \___||____/ |__|__|\____||__||__| |____/
A Python API client for BitTorrent Sync
Installation
Install from PyPI:
$ 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 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:
>>> import btsync
>>> client = btsync.Client(
... host='127.0.0.1',
... port='1106',
... username='admin',
... password='password')
Listing sync folders:
>>> import pprint
>>> pprint.pprint(client.sync_folders)
[{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:
>>> secret = client.generate_secret()
>>> pprint.pprint(secret)
{u'rosecret': u'--------------------------------',
u'secret': u'--------------------------------'}
Add a sync folder:
>>> client.add_sync_folder('/tmp', secret['rosecret'])
>>> pprint.pprint(client.sync_folders[1])
{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:
$ fab test_integration
Optionally, you can set an environment variable BTSYNC before running the test:
$ BTSYNC=$HOME/btsync/btsync fab test_integration
To run coverage for integration tests:
$ fab coverage:integration
You can also change the port the btsync instance for integration test runs on (the default port is 59999):
$ BTSYNC_PORT=55555 fab test_integration
License
See LICENSE.
Release files for btsync.py 0.9.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| btsync.py-0.9.9.tar.gz | 6.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| btsync.py-0.9.9-py2.7.egg | Legacy Egg format | - | - | Details |
Total release size: 17.9 kB
Release files / btsync.py-0.9.9.tar.gz
| Download URL | btsync.py-0.9.9.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
618fca004b556b0d862ff37d586c5369fcc3e2333d9304abcc858b65dc759417
|
|
BLAKE2b-256 checksum How to use checksums |
f8704949f7b06ff9534166a340baa2d8d9f94dd2f7dc1f6e0a21089ac386c981
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / btsync.py-0.9.9-py2.7.egg
| Download URL | btsync.py-0.9.9-py2.7.egg |
|---|---|
| Size | 11.8 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
278a3a79b127c8ee757c14f245e35dd3bc1942b78d5f38d8c1b5200d050647e2
|
|
BLAKE2b-256 checksum How to use checksums |
10d13fc8b14cb48901c73f74f753f00ded89a44eb202462e0a63fcdf4e772b58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |