[Python-modules-commits] [python-cassandra-driver] 01/02: Imported Upstream version 2.5.1
Sandro Tosi
morph at moszumanska.debian.org
Fri Jun 26 13:20:48 UTC 2015
This is an automated email from the git hooks/post-receive script.
morph pushed a commit to branch master
in repository python-cassandra-driver.
commit 0d98c1953f1928a3d04067ce898b27d4a4200053
Author: Sandro Tosi <morph at debian.org>
Date: Fri Jun 26 09:20:16 2015 -0400
Imported Upstream version 2.5.1
---
LICENSE | 177 ++
MANIFEST.in | 1 +
PKG-INFO | 99 +
README.rst | 75 +
cassandra/__init__.py | 304 +++
cassandra/auth.py | 177 ++
cassandra/cluster.py | 3152 ++++++++++++++++++++++++
cassandra/concurrent.py | 196 ++
cassandra/connection.py | 856 +++++++
cassandra/cqlengine/__init__.py | 41 +
cassandra/cqlengine/columns.py | 926 +++++++
cassandra/cqlengine/connection.py | 215 ++
cassandra/cqlengine/functions.py | 133 +
cassandra/cqlengine/management.py | 538 ++++
cassandra/cqlengine/models.py | 976 ++++++++
cassandra/cqlengine/named.py | 138 ++
cassandra/cqlengine/operators.py | 99 +
cassandra/cqlengine/query.py | 1207 +++++++++
cassandra/cqlengine/statements.py | 837 +++++++
cassandra/cqlengine/usertype.py | 204 ++
cassandra/cqltypes.py | 1075 ++++++++
cassandra/decoder.py | 58 +
cassandra/encoder.py | 212 ++
cassandra/io/__init__.py | 14 +
cassandra/io/asyncorereactor.py | 349 +++
cassandra/io/eventletreactor.py | 193 ++
cassandra/io/geventreactor.py | 189 ++
cassandra/io/libevreactor.py | 395 +++
cassandra/io/libevwrapper.c | 542 ++++
cassandra/io/twistedreactor.py | 259 ++
cassandra/marshal.py | 84 +
cassandra/metadata.py | 1436 +++++++++++
cassandra/metrics.py | 166 ++
cassandra/murmur3.c | 268 ++
cassandra/policies.py | 825 +++++++
cassandra/pool.py | 712 ++++++
cassandra/protocol.py | 998 ++++++++
cassandra/query.py | 901 +++++++
cassandra/util.py | 1001 ++++++++
cassandra_driver.egg-info/PKG-INFO | 99 +
cassandra_driver.egg-info/SOURCES.txt | 45 +
cassandra_driver.egg-info/dependency_links.txt | 1 +
cassandra_driver.egg-info/requires.txt | 2 +
cassandra_driver.egg-info/top_level.txt | 1 +
ez_setup.py | 258 ++
setup.cfg | 5 +
setup.py | 287 +++
47 files changed, 20726 insertions(+)
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..f433b1a
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..1825f7b
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1 @@
+include setup.py README.rst MANIFEST.in LICENSE ez_setup.py
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..6571faa
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,99 @@
+Metadata-Version: 1.1
+Name: cassandra-driver
+Version: 2.5.1
+Summary: Python driver for Cassandra
+Home-page: http://github.com/datastax/python-driver
+Author: Tyler Hobbs
+Author-email: tyler at datastax.com
+License: UNKNOWN
+Description: DataStax Python Driver for Apache Cassandra
+ ===========================================
+
+ .. image:: https://travis-ci.org/datastax/python-driver.png?branch=master
+ :target: https://travis-ci.org/datastax/python-driver
+
+ A Python client driver for Apache Cassandra. This driver works exclusively
+ with the Cassandra Query Language v3 (CQL3) and Cassandra's native
+ protocol. Cassandra versions 1.2 through 2.1 are supported.
+
+ The driver supports Python 2.6, 2.7, 3.3, and 3.4*.
+
+ * cqlengine component presently supports Python 2.7+
+
+ Installation
+ ------------
+ Installation through pip is recommended::
+
+ $ pip install cassandra-driver
+
+ For more complete installation instructions, see the
+ `installation guide <http://datastax.github.io/python-driver/installation.html>`_.
+
+ Documentation
+ -------------
+ The documentation can be found online `here <http://datastax.github.io/python-driver/index.html>`_.
+
+ A couple of links for getting up to speed:
+
+ * `Installation <http://datastax.github.io/python-driver/installation.html>`_
+ * `Getting started guide <http://datastax.github.io/python-driver/getting_started.html>`_
+ * `API docs <http://datastax.github.io/python-driver/api/index.html>`_
+ * `Performance tips <http://datastax.github.io/python-driver/performance.html>`_
+
+ Object Mapper
+ -------------
+ cqlengine (originally developed by Blake Eggleston and Jon Haddad, with contributions from the
+ community) is now maintained as an integral part of this package. Refer to
+ `documentation here <http://datastax.github.io/python-driver/object_mapper.html>`_.
+
+ Reporting Problems
+ ------------------
+ Please report any bugs and make any feature requests on the
+ `JIRA <https://datastax-oss.atlassian.net/browse/PYTHON>`_ issue tracker.
+
+ If you would like to contribute, please feel free to open a pull request.
+
+ Getting Help
+ ------------
+ Your two best options for getting help with the driver are the
+ `mailing list <https://groups.google.com/a/lists.datastax.com/forum/#!forum/python-driver-user>`_
+ and the IRC channel.
+
+ For IRC, use the #datastax-drivers channel on irc.freenode.net. If you don't have an IRC client,
+ you can use `freenode's web-based client <http://webchat.freenode.net/?channels=#datastax-drivers>`_.
+
+ Features to be Added
+ --------------------
+ * C extension for encoding/decoding messages
+
+ License
+ -------
+ Copyright 2013-2015 DataStax
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+Keywords: cassandra,cql,orm
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: Natural Language :: English
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..e976f93
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,75 @@
+DataStax Python Driver for Apache Cassandra
+===========================================
+
+.. image:: https://travis-ci.org/datastax/python-driver.png?branch=master
+ :target: https://travis-ci.org/datastax/python-driver
+
+A Python client driver for Apache Cassandra. This driver works exclusively
+with the Cassandra Query Language v3 (CQL3) and Cassandra's native
+protocol. Cassandra versions 1.2 through 2.1 are supported.
+
+The driver supports Python 2.6, 2.7, 3.3, and 3.4*.
+
+* cqlengine component presently supports Python 2.7+
+
+Installation
+------------
+Installation through pip is recommended::
+
+ $ pip install cassandra-driver
+
+For more complete installation instructions, see the
+`installation guide <http://datastax.github.io/python-driver/installation.html>`_.
+
+Documentation
+-------------
+The documentation can be found online `here <http://datastax.github.io/python-driver/index.html>`_.
+
+A couple of links for getting up to speed:
+
+* `Installation <http://datastax.github.io/python-driver/installation.html>`_
+* `Getting started guide <http://datastax.github.io/python-driver/getting_started.html>`_
+* `API docs <http://datastax.github.io/python-driver/api/index.html>`_
+* `Performance tips <http://datastax.github.io/python-driver/performance.html>`_
+
+Object Mapper
+-------------
+cqlengine (originally developed by Blake Eggleston and Jon Haddad, with contributions from the
+community) is now maintained as an integral part of this package. Refer to
+`documentation here <http://datastax.github.io/python-driver/object_mapper.html>`_.
+
+Reporting Problems
+------------------
+Please report any bugs and make any feature requests on the
+`JIRA <https://datastax-oss.atlassian.net/browse/PYTHON>`_ issue tracker.
+
+If you would like to contribute, please feel free to open a pull request.
+
+Getting Help
+------------
+Your two best options for getting help with the driver are the
+`mailing list <https://groups.google.com/a/lists.datastax.com/forum/#!forum/python-driver-user>`_
+and the IRC channel.
+
+For IRC, use the #datastax-drivers channel on irc.freenode.net. If you don't have an IRC client,
+you can use `freenode's web-based client <http://webchat.freenode.net/?channels=#datastax-drivers>`_.
+
+Features to be Added
+--------------------
+* C extension for encoding/decoding messages
+
+License
+-------
+Copyright 2013-2015 DataStax
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/cassandra/__init__.py b/cassandra/__init__.py
new file mode 100644
index 0000000..2be5700
--- /dev/null
+++ b/cassandra/__init__.py
@@ -0,0 +1,304 @@
+# Copyright 2013-2015 DataStax, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import logging
+
+
+class NullHandler(logging.Handler):
+
+ def emit(self, record):
+ pass
+
+logging.getLogger('cassandra').addHandler(NullHandler())
+
+
+__version_info__ = (2, 5, 1)
+__version__ = '.'.join(map(str, __version_info__))
+
+
+class ConsistencyLevel(object):
+ """
+ Spcifies how many replicas must respond for an operation to be considered
+ a success. By default, ``ONE`` is used for all operations.
+ """
+
+ ANY = 0
+ """
+ Only requires that one replica receives the write *or* the coordinator
+ stores a hint to replay later. Valid only for writes.
+ """
+
+ ONE = 1
+ """
+ Only one replica needs to respond to consider the operation a success
+ """
+
+ TWO = 2
+ """
+ Two replicas must respond to consider the operation a success
+ """
+
+ THREE = 3
+ """
+ Three replicas must respond to consider the operation a success
+ """
+
+ QUORUM = 4
+ """
+ ``ceil(RF/2)`` replicas must respond to consider the operation a success
+ """
+
+ ALL = 5
+ """
+ All replicas must respond to consider the operation a success
+ """
+
+ LOCAL_QUORUM = 6
+ """
+ Requires a quorum of replicas in the local datacenter
+ """
+
+ EACH_QUORUM = 7
+ """
+ Requires a quorum of replicas in each datacenter
+ """
+
+ SERIAL = 8
+ """
+ For conditional inserts/updates that utilize Cassandra's lightweight
+ transactions, this requires consensus among all replicas for the
+ modified data.
+ """
+
+ LOCAL_SERIAL = 9
+ """
+ Like :attr:`~ConsistencyLevel.SERIAL`, but only requires consensus
+ among replicas in the local datacenter.
+ """
+
+ LOCAL_ONE = 10
+ """
+ Sends a request only to replicas in the local datacenter and waits for
+ one response.
+ """
+
+ConsistencyLevel.value_to_name = {
+ ConsistencyLevel.ANY: 'ANY',
+ ConsistencyLevel.ONE: 'ONE',
+ ConsistencyLevel.TWO: 'TWO',
+ ConsistencyLevel.THREE: 'THREE',
+ ConsistencyLevel.QUORUM: 'QUORUM',
+ ConsistencyLevel.ALL: 'ALL',
+ ConsistencyLevel.LOCAL_QUORUM: 'LOCAL_QUORUM',
+ ConsistencyLevel.EACH_QUORUM: 'EACH_QUORUM',
+ ConsistencyLevel.SERIAL: 'SERIAL',
+ ConsistencyLevel.LOCAL_SERIAL: 'LOCAL_SERIAL',
+ ConsistencyLevel.LOCAL_ONE: 'LOCAL_ONE'
+}
+
+ConsistencyLevel.name_to_value = {
+ 'ANY': ConsistencyLevel.ANY,
+ 'ONE': ConsistencyLevel.ONE,
+ 'TWO': ConsistencyLevel.TWO,
+ 'THREE': ConsistencyLevel.THREE,
+ 'QUORUM': ConsistencyLevel.QUORUM,
+ 'ALL': ConsistencyLevel.ALL,
+ 'LOCAL_QUORUM': ConsistencyLevel.LOCAL_QUORUM,
+ 'EACH_QUORUM': ConsistencyLevel.EACH_QUORUM,
+ 'SERIAL': ConsistencyLevel.SERIAL,
+ 'LOCAL_SERIAL': ConsistencyLevel.LOCAL_SERIAL,
+ 'LOCAL_ONE': ConsistencyLevel.LOCAL_ONE
+}
+
+
+def consistency_value_to_name(value):
+ return ConsistencyLevel.value_to_name[value] if value is not None else "Not Set"
+
+
+class Unavailable(Exception):
+ """
+ There were not enough live replicas to satisfy the requested consistency
+ level, so the coordinator node immediately failed the request without
+ forwarding it to any replicas.
+ """
+
+ consistency = None
+ """ The requested :class:`ConsistencyLevel` """
+
+ required_replicas = None
+ """ The number of replicas that needed to be live to complete the operation """
+
+ alive_replicas = None
+ """ The number of replicas that were actually alive """
+
+ def __init__(self, summary_message, consistency=None, required_replicas=None, alive_replicas=None):
+ self.consistency = consistency
+ self.required_replicas = required_replicas
+ self.alive_replicas = alive_replicas
+ Exception.__init__(self, summary_message + ' info=' +
+ repr({'consistency': consistency_value_to_name(consistency),
+ 'required_replicas': required_replicas,
+ 'alive_replicas': alive_replicas}))
+
+
+class Timeout(Exception):
+ """
+ Replicas failed to respond to the coordinator node before timing out.
+ """
+
+ consistency = None
+ """ The requested :class:`ConsistencyLevel` """
+
+ required_responses = None
+ """ The number of required replica responses """
+
+ received_responses = None
+ """
+ The number of replicas that responded before the coordinator timed out
+ the operation
+ """
+
+ def __init__(self, summary_message, consistency=None, required_responses=None, received_responses=None):
+ self.consistency = consistency
+ self.required_responses = required_responses
+ self.received_responses = received_responses
+ Exception.__init__(self, summary_message + ' info=' +
+ repr({'consistency': consistency_value_to_name(consistency),
+ 'required_responses': required_responses,
+ 'received_responses': received_responses}))
+
+
+class ReadTimeout(Timeout):
+ """
+ A subclass of :exc:`Timeout` for read operations.
+
+ This indicates that the replicas failed to respond to the coordinator
+ node before the configured timeout. This timeout is configured in
+ ``cassandra.yaml`` with the ``read_request_timeout_in_ms``
+ and ``range_request_timeout_in_ms`` options.
+ """
+
+ data_retrieved = None
+ """
+ A boolean indicating whether the requested data was retrieved
+ by the coordinator from any replicas before it timed out the
+ operation
+ """
+
+ def __init__(self, message, data_retrieved=None, **kwargs):
+ Timeout.__init__(self, message, **kwargs)
+ self.data_retrieved = data_retrieved
+
+
+class WriteTimeout(Timeout):
+ """
+ A subclass of :exc:`Timeout` for write operations.
+
+ This indicates that the replicas failed to respond to the coordinator
+ node before the configured timeout. This timeout is configured in
+ ``cassandra.yaml`` with the ``write_request_timeout_in_ms``
+ option.
+ """
+
+ write_type = None
+ """
+ The type of write operation, enum on :class:`~cassandra.policies.WriteType`
+ """
+
+ def __init__(self, message, write_type=None, **kwargs):
+ Timeout.__init__(self, message, **kwargs)
+ self.write_type = write_type
+
+
+class AlreadyExists(Exception):
+ """
+ An attempt was made to create a keyspace or table that already exists.
+ """
+
+ keyspace = None
+ """
+ The name of the keyspace that already exists, or, if an attempt was
+ made to create a new table, the keyspace that the table is in.
+ """
+
+ table = None
+ """
+ The name of the table that already exists, or, if an attempt was
+ make to create a keyspace, :const:`None`.
+ """
+
+ def __init__(self, keyspace=None, table=None):
+ if table:
+ message = "Table '%s.%s' already exists" % (keyspace, table)
+ else:
+ message = "Keyspace '%s' already exists" % (keyspace,)
+
+ Exception.__init__(self, message)
+ self.keyspace = keyspace
+ self.table = table
+
+
+class InvalidRequest(Exception):
+ """
+ A query was made that was invalid for some reason, such as trying to set
+ the keyspace for a connection to a nonexistent keyspace.
+ """
+ pass
+
+
+class Unauthorized(Exception):
+ """
+ The current user is not authorized to perfom the requested operation.
+ """
+ pass
+
+
+class AuthenticationFailed(Exception):
+ """
+ Failed to authenticate.
+ """
+ pass
+
+
+class OperationTimedOut(Exception):
+ """
+ The operation took longer than the specified (client-side) timeout
+ to complete. This is not an error generated by Cassandra, only
+ the driver.
+ """
+
+ errors = None
+ """
+ A dict of errors keyed by the :class:`~.Host` against which they occurred.
+ """
+
+ last_host = None
+ """
+ The last :class:`~.Host` this operation was attempted against.
+ """
+
+ def __init__(self, errors=None, last_host=None):
+ self.errors = errors
+ self.last_host = last_host
+ message = "errors=%s, last_host=%s" % (self.errors, self.last_host)
+ Exception.__init__(self, message)
+
+
+class UnsupportedOperation(Exception):
+ """
+ An attempt was made to use a feature that is not supported by the
+ selected protocol version. See :attr:`Cluster.protocol_version`
+ for more details.
+ """
+ pass
diff --git a/cassandra/auth.py b/cassandra/auth.py
new file mode 100644
index 0000000..67d302a
--- /dev/null
+++ b/cassandra/auth.py
@@ -0,0 +1,177 @@
+# Copyright 2013-2015 DataStax, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+try:
+ from puresasl.client import SASLClient
+except ImportError:
+ SASLClient = None
+
+class AuthProvider(object):
+ """
+ An abstract class that defines the interface that will be used for
+ creating :class:`~.Authenticator` instances when opening new
+ connections to Cassandra.
+
+ .. versionadded:: 2.0.0
+ """
+
+ def new_authenticator(self, host):
+ """
+ Implementations of this class should return a new instance
+ of :class:`~.Authenticator` or one of its subclasses.
+ """
+ raise NotImplementedError()
+
+
+class Authenticator(object):
+ """
+ An abstract class that handles SASL authentication with Cassandra servers.
+
+ Each time a new connection is created and the server requires authentication,
+ a new instance of this class will be created by the corresponding
+ :class:`~.AuthProvider` to handler that authentication. The lifecycle of the
+ new :class:`~.Authenticator` will the be:
+
+ 1) The :meth:`~.initial_response()` method will be called. The return
+ value will be sent to the server to initiate the handshake.
+
+ 2) The server will respond to each client response by either issuing a
+ challenge or indicating that the authentication is complete (successful or not).
+ If a new challenge is issued, :meth:`~.evaluate_challenge()`
+ will be called to produce a response that will be sent to the
+ server. This challenge/response negotiation will continue until the server
+ responds that authentication is successful (or an :exc:`~.AuthenticationFailed`
+ is raised).
+
+ 3) When the server indicates that authentication is successful,
+ :meth:`~.on_authentication_success` will be called a token string that
+ that the server may optionally have sent.
+
+ The exact nature of the negotiation between the client and server is specific
+ to the authentication mechanism configured server-side.
+
+ .. versionadded:: 2.0.0
+ """
+
+ def initial_response(self):
+ """
+ Returns an message to send to the server to initiate the SASL handshake.
+ :const:`None` may be returned to send an empty message.
+ """
+ return None
+
+ def evaluate_challenge(self, challenge):
+ """
+ Called when the server sends a challenge message. Generally, this method
+ should return :const:`None` when authentication is complete from a
+ client perspective. Otherwise, a string should be returned.
+ """
+ raise NotImplementedError()
+
+ def on_authentication_success(self, token):
+ """
+ Called when the server indicates that authentication was successful.
+ Depending on the authentication mechanism, `token` may be :const:`None`
+ or a string.
+ """
+ pass
+
+
+class PlainTextAuthProvider(AuthProvider):
+ """
+ An :class:`~.AuthProvider` that works with Cassandra's PasswordAuthenticator.
+
+ Example usage::
+
+ from cassandra.cluster import Cluster
+ from cassandra.auth import PlainTextAuthProvider
+
+ auth_provider = PlainTextAuthProvider(
+ username='cassandra', password='cassandra')
+ cluster = Cluster(auth_provider=auth_provider)
+
+ .. versionadded:: 2.0.0
+ """
+
+ def __init__(self, username, password):
+ self.username = username
+ self.password = password
+
+ def new_authenticator(self, host):
+ return PlainTextAuthenticator(self.username, self.password)
+
+
+class PlainTextAuthenticator(Authenticator):
+ """
+ An :class:`~.Authenticator` that works with Cassandra's PasswordAuthenticator.
+
+ .. versionadded:: 2.0.0
+ """
+
+ def __init__(self, username, password):
+ self.username = username
+ self.password = password
+
+ def initial_response(self):
+ return "\x00%s\x00%s" % (self.username, self.password)
+
+ def evaluate_challenge(self, challenge):
+ return None
+
+
+class SaslAuthProvider(AuthProvider):
+ """
+ An :class:`~.AuthProvider` supporting general SASL auth mechanisms
+
+ Suitable for GSSAPI or other SASL mechanisms
+
+ Example usage::
+
+ from cassandra.cluster import Cluster
+ from cassandra.auth import SaslAuthProvider
+
+ sasl_kwargs = {'host': 'localhost',
+ 'service': 'dse',
+ 'mechanism': 'GSSAPI',
+ 'qops': 'auth'.split(',')}
+ auth_provider = SaslAuthProvider(**sasl_kwargs)
+ cluster = Cluster(auth_provider=auth_provider)
+
+ .. versionadded:: 2.1.4
+ """
+
+ def __init__(self, **sasl_kwargs):
+ if SASLClient is None:
+ raise ImportError('The puresasl library has not been installed')
+ self.sasl_kwargs = sasl_kwargs
+
+ def new_authenticator(self, host):
+ return SaslAuthenticator(**self.sasl_kwargs)
+
+class SaslAuthenticator(Authenticator):
+ """
+ A pass-through :class:`~.Authenticator` using the third party package
+ 'pure-sasl' for authentication
+
+ .. versionadded:: 2.1.4
+ """
+
+ def __init__(self, host, service, mechanism='GSSAPI', **sasl_kwargs):
+ if SASLClient is None:
+ raise ImportError('The puresasl library has not been installed')
+ self.sasl = SASLClient(host, service, mechanism, **sasl_kwargs)
+
+ def initial_response(self):
+ return self.sasl.process()
+
+ def evaluate_challenge(self, challenge):
+ return self.sasl.process(challenge)
diff --git a/cassandra/cluster.py b/cassandra/cluster.py
new file mode 100644
index 0000000..c7b2be7
--- /dev/null
+++ b/cassandra/cluster.py
@@ -0,0 +1,3152 @@
+# Copyright 2013-2015 DataStax, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+This module houses the main classes you will interact with,
+:class:`.Cluster` and :class:`.Session`.
+"""
+from __future__ import absolute_import
+
+import atexit
+from collections import defaultdict
+from concurrent.futures import ThreadPoolExecutor
+import logging
+from random import random
+import socket
+import sys
+import time
+from threading import Lock, RLock, Thread, Event
+
+import six
+from six.moves import range
+from six.moves import queue as Queue
+
+import weakref
+from weakref import WeakValueDictionary
+try:
+ from weakref import WeakSet
+except ImportError:
+ from cassandra.util import WeakSet # NOQA
+
+from functools import partial, wraps
+from itertools import groupby
+
+from cassandra import (ConsistencyLevel, AuthenticationFailed,
+ InvalidRequest, OperationTimedOut,
+ UnsupportedOperation, Unauthorized)
+from cassandra.connection import (ConnectionException, ConnectionShutdown,
+ ConnectionHeartbeat)
+from cassandra.cqltypes import UserType
+from cassandra.encoder import Encoder
+from cassandra.protocol import (QueryMessage, ResultMessage,
+ ErrorMessage, ReadTimeoutErrorMessage,
+ WriteTimeoutErrorMessage,
+ UnavailableErrorMessage,
+ OverloadedErrorMessage,
+ PrepareMessage, ExecuteMessage,
+ PreparedQueryNotFound,
+ IsBootstrappingErrorMessage,
+ BatchMessage, RESULT_KIND_PREPARED,
+ RESULT_KIND_SET_KEYSPACE, RESULT_KIND_ROWS,
+ RESULT_KIND_SCHEMA_CHANGE)
+from cassandra.metadata import Metadata, protect_name
+from cassandra.policies import (RoundRobinPolicy, SimpleConvictionPolicy,
+ ExponentialReconnectionPolicy, HostDistance,
+ RetryPolicy)
+from cassandra.pool import (Host, _ReconnectionHandler, _HostReconnectionHandler,
+ HostConnectionPool, HostConnection,
+ NoConnectionsAvailable)
+from cassandra.query import (SimpleStatement, PreparedStatement, BoundStatement,
... 20064 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-cassandra-driver.git
More information about the Python-modules-commits
mailing list