Skip to content

Latest commit

 

History

History
127 lines (79 loc) · 4.38 KB

README.md

File metadata and controls

127 lines (79 loc) · 4.38 KB

datpy

This is a python client for Dat'.

travis pypi pypi

What is Dat?

Dat is a peer-to-peer data sync tool. Read the docs to learn more about Dat.

Installation

  1. Install dat
`npm install -g dat`
  1. Install datpy
`pip install datpy`

Usage

This is a new library and it needs work! Please don't hesitate to send a pull request or to open an issue if you find something wrong or broken.

datpy.Dat(home='')

Dat is a class that binds to some global Dat. You can provide an optional home variable to pass to the dat cli to store your data somewhere besides your local machine. By default, the metadata storage is placed in ~/.dat.

> import datpy
> mydat = datpy.Dat()

For each command, a dat instance accepts any of the options supported by Dat's commandline api.

mydat.share(path)

Creates a fingerprinted dat link to the data. This is a unique link that can be given to download. This will open a TCP connection to the public network to share the data.

Example:

> mydat.share('./path/to/my/data')
'a53d819bdf5c3496a2855df83daaac885686cac4b0bccfc580741b04898e3b32'

mydat.download(link, path)

Downloads the link to the local hard drive. This will open a TCP connection to the public network to connect to the swarm assocaited to this link. It will download the data and will remain open to re-host it for redundancy. You can provide an optional path argument to download the data to a specific folder.

> dat.download('a53d819bdf5c3496a2855df83daaac885686cac4b0bccfc580741b04898e3b32', 'data')

mydat.close()

Closes any connections opened with download or link.

Development

We recommend using virtualenv to develop datpy. Set up your environment like this:

$ virtualenv env

And then every time you want to start developing, do this:

$ source env/bin/activate
$ python setup.py develop

Contributing

First, create a fork, then install the requirements. Make your change and open a pull request. You might need to create a virtual environment, depending on your setup.

$ git clone http://github.com/<your-fork>/datpy
$ pip install -r requirements.txt
$ git commit -am "BUG: there was a bug here fixes #33"
$ git push origin master
 ... open pull request!

Testing

python -m 'nose'

To run just one test

python -m 'nose' tests/test.py:IOTests.test_link_and_download

To run Python 3 tests

python3 -m 'nose'

Publishing

First, edit setup.py to bump the version number on both the version key and the download_url. Then, to push to pip/pypi:

python setup.py register -r pypi
python setup.py sdist upload -r pypi

BSD Licensed

Copyright (c) 2014 Karissa McKelvey and contributors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.