Skip to main content

A python client for etcd

Project description

python-etcd documentation

A python client for Etcd https://github.com/coreos/etcd

Official documentation: http://python-etcd.readthedocs.org/

https://api.travis-ci.org/jplana/python-etcd.png

Installation

Pre-requirements

Install etcd

From source

$ python setup.py install

Usage

Create a client object

import etcd

client = etcd.Client() # this will create a client against etcd server running on localhost on port 4001
client = etcd.Client(port=4002)
client = etcd.Client(host='127.0.0.1', port=4003)
client = etcd.Client(host='127.0.0.1', port=4003, allow_redirect=False) # wont let you run sensitive commands on non-leader machines, default is true

Set a key

client.set('/nodes/n1', 1)
# with ttl
client.set('/nodes/n2', 2, ttl=4)  # sets the ttl to 4 seconds

Get a key

client.get('/nodes/n2').value

Delete a key

client.delete('/nodes/n1')

Test and set

client.test_and_set('/nodes/n2', 2, 4) # will set /nodes/n2 's value to 2 only if its previous value was 4

Watch a key

client.watch('/nodes/n1') # will wait till the key is changed, and return once its changed

List sub keys

# List nodes in the cluster
client.get('/nodes')

# List keys under /subtree
client.get('/subtree')

Get machines in the cluster

client.machines

Get leader of the cluster

client.leader

Development setup

To create a buildout,

$ python bootstrap.py
$ bin/buildout

to test you should have etcd available in your system path:

$ bin/test

to generate documentation,

$ cd docs
$ make

Release HOWTO

To make a release

  1. Update release date/version in NEWS.txt and setup.py

  2. Run ‘python setup.py sdist’

  3. Test the generated source distribution in dist/

  4. Upload to PyPI: ‘python setup.py sdist register upload’

News

0.1

Release date: 18-Sep-2013

  • Initial release

0.2.0

Release data: 30-Sep-2013

  • Allow fetching of multiple keys (sub-nodes)

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

python-etcd-0.2.0.tar.gz (10.2 kB view details)

Uploaded Source

File details

Details for the file python-etcd-0.2.0.tar.gz.

File metadata

  • Download URL: python-etcd-0.2.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for python-etcd-0.2.0.tar.gz
Algorithm Hash digest
SHA256 101a2dfb7948bda8c69177082ad2b6e469bca143defc36cf83bfbb956ba88d5e
MD5 5196caa76bc2361d8297126211324b4d
BLAKE2b-256 da578081a66f28c268fa809350acd7cf4b7a3625931b908b0866cf011c0f1324

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