{ "info": { "author": "Njal Karevoll", "author_email": "njal@karevoll.no", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7" ], "description": "# pykeeper: Higher-level bindings for ZooKeeper\n\n\nThe aim of this project is providing a higher level API over the official low level Python ZooKeeper bindings (zkpython).\n\nFor django support see [djkeeper](http://github.com/nkvoll/djkeeper).\n\n\n## Features\n\n * Automatic reconnection\n * Recursive delete\n * Recursive create\n * Cached versions of: [get (cached_get), get_children (cached_get_children), exists (cached_exists)]\n * Easy handling and masking of temporary disconnects/reconnects.\n\n\n## Installing\n\nEither install the latest relase from PYPI:\n\n $ pip install pykeeper\n\n... or get the latest development version from GitHub:\n\n $ pip install https://github.com/nkvoll/pykeeper/zipball/develop#egg=pykeeper\n\nAdditionally, pykeeper requires a working installation of the official low level Python ZooKeeper bindings. These can either be built from source (recommended, explanation below), or\nyou could install the statically compiled version [zc-zookeeper-static](http://pypi.python.org/pypi/zc-zookeeper-static)) from PYPI, which may or may not work on your architecture/OS, and may\nor may not be the latest available ZooKeeper version.\n\n\n### Installing ZooKeeper on OS X (homebrew)\n\nIf you don't have homebrew, follow the Linux installation below, skipping \"ldconfig\", otherwise, use homebrew to install zookeeper with the ``--python`` flag:\n\n $ brew install --python zookeeper\n\n\n### Installing ZooKeeper on Linux\n\nDownload and unpack the latest release of ZooKeeper from http://zookeeper.apache.org/releases.html:\n\n $ tar -zxvf zookeeper-3.4.2.tar.gz\n\nBuild the C bindings:\n\n $ cd zookeeper-3.4.2/src/c\n $ ./configure --prefix=/usr/local\n $ make\n $ sudo make install\n $ ldconfig\n\nBuild and install the python bindings:\n\n $ cd ../contrib/zkpython\n $ ant install\n\n\n## Running the test-suite\n\nThe test suite assumes you have a ZooKeeper server running on localhost:22181:\n\n $ cd example\n $ export ZOOCFGDIR=$(pwd) zkServer start-foreground\n\nzkServer / zkServer.sh is found in the ZooKeeper installation directory.\n\nThe tests can then be run via the setup.py script:\n\n $ python setup.py nosetests -with-doctest --verbosity=2\n\n\n## Example usage\n\n $ python\n >>> import pykeeper\n\n # (optional) redirect zookeeper logging to the python \"logging\" package, using the \"zookeeper\" logger.\n # doing this prevents zookeeper from writing a lot of garbage to sys.stderr, and makes enables handling\n # the logging output via the default python logging facilities. this behaviour is optional and can be\n # switched off at any time later by calling pykeeper.uninstall_log_stream()\n >>> pykeeper.install_log_stream()\n\n # Create a ZooKeeper client and connect:\n >>> client = pykeeper.ZooKeeper('localhost:22181')\n >>> client.connect()\n\n >>> client.get_children('/')\n ['zookeeper']\n\n # creating a node:\n >>> client.create_recursive('/bar/baz', '{\"ok\": true}')\n >>> client.get_children('/')\n ['bar', 'zookeeper']\n >>> bool(client.exists('/bar/baz'))\n True\n >>> client.get_children('/bar')\n ['baz']\n >>> client.get('/bar/baz')\n ('{\"ok\": true}', {'pzxid': 3620L, 'ctime': 1328717487776L, 'aversion': 0, 'mzxid': 3620L, 'numChildren': 0, 'ephemeralOwner': 0L, 'version': 0, 'dataLength': 12, 'mtime': 1328717487776L, 'cversion': 0, 'czxid': 3620L})\n\n # delete the node:\n >>> client.delete_recursive('/bar')\n >>> bool(client.exists('/bar'))\n False\n >>> client.get_children('/')\n ['foo', 'zookeeper']\n\n # since the node does not exist, trying to get its data raises an exception:\n >>> client.get('/bar')\n Traceback (most recent call last):\n File \"\", line 1, in \n File \"pykeeper/client.py\", line 176, in get\n return zookeeper.get(self.handle, path, self._wrap_watcher(watcher))\n zookeeper.NoNodeException: no node\n\n\n### Handling transient connection errors/losses\n\n\nIf we lose connection to the ZooKeeper server, calls on the client will raise an exception:\n\n >>> client.get('/')\n Traceback (most recent call last):\n File \"\", line 1, in \n File \"pykeeper/client.py\", line 176, in get\n return zookeeper.get(self.handle, path, self._wrap_watcher(watcher))\n zookeeper.ConnectionLossException: connection loss\n\nWe can wait until the connection is re-established by calling ``client.wait_until_connected()`` with an optional timeout. The default timeout is ``None``, which means the call will block until the connection is re-established:\n\n >>> client.state_name\n 'connecting'\n >>> client.wait_until_connected()\n >>> client.state_name\n 'connected'\n\nIf the connection is not re-established before the timeout occurs, a TimeoutException is raised:\n\n >>> client.state_name\n 'connecting'\n >>> client.wait_until_connected(timeout=10)\n Traceback (most recent call last):\n File \"\", line 1, in \n File \"pykeeper/client.py\", line 130, in wait_until_connected\n raise TimeoutException()\n pykeeper.client.TimeoutException\n >>> client.state_name\n 'connecting'\n\n\n## Troubleshooting\n\n### Q: Why do I get a ``TypeError`` when I call any functions on the client?\n\nA: Most likely, you attempted to do something along the following lines:\n\n >>> import pykeeper\n >>> client = pykeeper.ZooKeeper('localhost:22181')\n >>> client.get_children('/')\n Traceback (most recent call last):\n File \"\", line 1, in \n File \"pykeeper/client.py\", line 153, in get_children\n return zookeeper.get_children(self.handle, path, self._wrap_watcher(watcher))\n TypeError: an integer is required\n\nThe problem is that you forgot to call ``client.connect()`` before using the client:\n\n >>> import pykeeper\n >>> client = pykeeper.ZooKeeper('localhost:22181')\n >>> client.connect()\n >>> client.get_children('/')\n ['zookeeper']\n\nAs usual, consider calling ``client.wait_until_connected(timeout=...)`` before using the client to ensure that the client has had time to connect to the ZooKeeper ensemble.\n\n### Q: I'm creating a multiple clients, and I seem to be leaking memory.\nA: Always close clients you are not going to use any more by calling ``client.close()``. Another solution is to re-use the clients instead of creating a new one every time you need one.\n\n\n## Notes\n\nCurrently, only the synchronous parts of the API is implemented.\n\n\n## License\n\nMIT licensed, see LICENSE for details.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/nkvoll/pykeeper", "keywords": "zookeeper", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "pykeeper", "package_url": "https://pypi.org/project/pykeeper/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pykeeper/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/nkvoll/pykeeper" }, "release_url": "https://pypi.org/project/pykeeper/0.2.1/", "requires_dist": null, "requires_python": null, "summary": "Higher-level bindings for ZooKeeper.", "version": "0.2.1" }, "last_serial": 797327, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "5dbd4a49bc318582851c37f1f25447f9", "sha256": "e9cad3d9bbbdfa1e12dc957bdd6a36dfeede476fe6126152c92ac9d8f4de77d5" }, "downloads": -1, "filename": "pykeeper-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5dbd4a49bc318582851c37f1f25447f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10317, "upload_time": "2012-02-08T18:11:18", "url": "https://files.pythonhosted.org/packages/5d/04/580aed8474bc0c60a6801c8ce31e879402e9f55a75717d88815ef587dba9/pykeeper-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "630a6484f725eeb3d96da0d05c6704a2", "sha256": "68ffa13940bb8aa05d13bf21c3aefac693fe00064ff0eb171e5a0303c19b22fe" }, "downloads": -1, "filename": "pykeeper-0.1.1.tar.gz", "has_sig": false, "md5_digest": "630a6484f725eeb3d96da0d05c6704a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10865, "upload_time": "2012-02-08T18:19:59", "url": "https://files.pythonhosted.org/packages/17/77/1b07fd764883e82b92f595b9495aab27c6c215bbead29ec0aef7b41d8792/pykeeper-0.1.1.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "0b7d487b247dfeae36396da7f2e01261", "sha256": "00bb577756795084108de6448927b2424175d1744af09084f89b3445fa5b7846" }, "downloads": -1, "filename": "pykeeper-0.2.1.tar.gz", "has_sig": false, "md5_digest": "0b7d487b247dfeae36396da7f2e01261", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11196, "upload_time": "2012-02-12T21:26:41", "url": "https://files.pythonhosted.org/packages/bb/0a/e24f68b697fbe9b0617329ae59f87096b3173a780dddb03657e886104181/pykeeper-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0b7d487b247dfeae36396da7f2e01261", "sha256": "00bb577756795084108de6448927b2424175d1744af09084f89b3445fa5b7846" }, "downloads": -1, "filename": "pykeeper-0.2.1.tar.gz", "has_sig": false, "md5_digest": "0b7d487b247dfeae36396da7f2e01261", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11196, "upload_time": "2012-02-12T21:26:41", "url": "https://files.pythonhosted.org/packages/bb/0a/e24f68b697fbe9b0617329ae59f87096b3173a780dddb03657e886104181/pykeeper-0.2.1.tar.gz" } ] }