Repository: cassandra Updated Branches: refs/heads/cassandra-2.1 c70216a5b -> d2ae187c7
Update cqlsh python driver to 2.1 Patch by Mikhail Stepura and Tyler Hobbs; reviewed by Aleksey Yeschenko for CASSANDRA-7509 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/88e05719 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/88e05719 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/88e05719 Branch: refs/heads/cassandra-2.1 Commit: 88e05719b6a36cfd8feeff852945c2fc1e9a536e Parents: 721afae Author: Tyler Hobbs <[email protected]> Authored: Wed Jul 16 11:54:31 2014 -0500 Committer: Tyler Hobbs <[email protected]> Committed: Wed Jul 16 11:56:29 2014 -0500 ---------------------------------------------------------------------- CHANGES.txt | 1 + bin/cqlsh | 44 +++-- lib/cassandra-driver-internal-only-1.1.2.zip | Bin 105983 -> 0 bytes ...sandra-driver-internal-only-2.1.0b1.post.zip | Bin 0 -> 125786 bytes lib/licenses/cassandra-driver-1.0.2.txt | 177 ------------------- lib/licenses/cassandra-driver-2.1.0b1.post.txt | 177 +++++++++++++++++++ lib/licenses/six-1.7.3.txt | 18 ++ lib/six-1.7.3-py2.py3-none-any.zip | Bin 0 -> 9503 bytes pylib/cqlshlib/formatting.py | 8 +- pylib/cqlshlib/test/test_cqlsh_completion.py | 2 +- pylib/cqlshlib/test/test_cqlsh_output.py | 2 +- pylib/cqlshlib/usertypes.py | 117 ------------ 12 files changed, 236 insertions(+), 310 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/88e05719/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 97528cd..a7f0cee 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -6,6 +6,7 @@ * Add missing table name to DROP INDEX responses and notifications (CASSANDRA-7539) * Bump CQL version to 3.2.0 and update CQL documentation (CASSANDRA-7527) * Fix configuration error message when running nodetool ring (CASSANDRA-7508) + * Support conditional updates, tuple type, and the v3 protocol in cqlsh (CASSANDRA-7509) Merged from 2.0: * (Windows) force range-based repair to non-sequential mode (CASSANDRA-7541) * Fix range merging when DES scores are zero (CASSANDRA-7535) http://git-wip-us.apache.org/repos/asf/cassandra/blob/88e05719/bin/cqlsh ---------------------------------------------------------------------- diff --git a/bin/cqlsh b/bin/cqlsh index 53f0c7c..76ff590 100755 --- a/bin/cqlsh +++ b/bin/cqlsh @@ -65,6 +65,7 @@ except ImportError: CQL_LIB_PREFIX = 'cassandra-driver-internal-only-' FUTURES_LIB_PREFIX = 'futures-' +SIX_LIB_PREFIX = 'six-' CASSANDRA_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..') @@ -91,6 +92,9 @@ if cql_zip: futures_zip = find_zip(FUTURES_LIB_PREFIX) if futures_zip: sys.path.insert(0, futures_zip) +six_zip = find_zip(SIX_LIB_PREFIX) +if six_zip: + sys.path.insert(0, six_zip) warnings.filterwarnings("ignore", r".*blist.*") try: @@ -113,13 +117,12 @@ cqlshlibdir = os.path.join(CASSANDRA_PATH, 'pylib') if os.path.isdir(cqlshlibdir): sys.path.insert(0, cqlshlibdir) -from cqlshlib import cqlhandling, cql3handling, pylexotron, usertypes, sslhandling +from cqlshlib import cqlhandling, cql3handling, pylexotron, sslhandling from cqlshlib.displaying import (RED, BLUE, ANSI_RESET, COLUMN_NAME_COLORS, FormattedValue, colorme) -from cqlshlib.formatting import format_by_type +from cqlshlib.formatting import format_by_type, formatter_for, format_value_utype from cqlshlib.util import trim_if_present from cqlshlib.tracing import print_trace_session -from cqlshlib.usertypes import deserialize_safe_collection, deserialize_safe_map HISTORY_DIR = os.path.expanduser(os.path.join('~', '.cassandra')) CONFIG_FILE = os.path.join(HISTORY_DIR, 'cqlshrc') @@ -140,6 +143,7 @@ if os.path.exists(OLD_HISTORY): DEFAULT_HOST = '127.0.0.1' DEFAULT_PORT = 9042 DEFAULT_CQLVER = '3.2.0' +DEFAULT_PROTOCOL_VERSION = 3 DEFAULT_TIME_FORMAT = '%Y-%m-%d %H:%M:%S%z' DEFAULT_FLOAT_PRECISION = 5 @@ -179,7 +183,7 @@ CQL_ERRORS = ( cassandra.Timeout, cassandra.Unauthorized, cassandra.OperationTimedOut, cassandra.cluster.NoHostAvailable, cassandra.connection.ConnectionBusy, cassandra.connection.ProtocolError, cassandra.connection.ConnectionException, - cassandra.decoder.ErrorMessage, cassandra.decoder.InternalError, cassandra.query.TraceUnavailable + cassandra.protocol.ErrorMessage, cassandra.protocol.InternalError, cassandra.query.TraceUnavailable ) debug_completion = bool(os.environ.get('CQLSH_DEBUG_COMPLETION', '') == 'YES') @@ -443,6 +447,26 @@ def describe_interval(seconds): words = desc[0] + ' and ' + words return words + +def auto_format_udts(): + # when we see a new user defined type, set up the shell formatting for it + udt_apply_params = cassandra.cqltypes.UserType.apply_parameters + def new_apply_params(cls, *args, **kwargs): + udt_class = udt_apply_params(*args, **kwargs) + formatter_for(udt_class.typename)(format_value_utype) + return udt_class + + cassandra.cqltypes.UserType.udt_apply_parameters = classmethod(new_apply_params) + + make_udt_class = cassandra.cqltypes.UserType.make_udt_class + def new_make_udt_class(cls, *args, **kwargs): + udt_class = make_udt_class(*args, **kwargs) + formatter_for(udt_class.typename)(format_value_utype) + return udt_class + + cassandra.cqltypes.UserType.make_udt_class = classmethod(new_make_udt_class) + + class Shell(cmd.Cmd): custom_prompt = os.getenv('CQLSH_PROMPT', '') if custom_prompt is not '': @@ -483,6 +507,7 @@ class Shell(cmd.Cmd): self.conn = use_conn else: self.conn = Cluster(contact_points=(self.hostname,), port=self.port, cql_version=cqlver, + protocol_version=DEFAULT_PROTOCOL_VERSION, auth_provider=self.auth_provider, ssl_options=sslhandling.ssl_settings(hostname, CONFIG_FILE) if ssl else None, load_balancing_policy=WhiteListRoundRobinPolicy([self.hostname])) @@ -525,17 +550,12 @@ class Shell(cmd.Cmd): #Python driver returns BLOBs as string, but we expect them as buffer() cassandra.cqltypes.BytesType.deserialize = staticmethod(cassandra.cqltypes.BytesType.validate) cassandra.cqltypes.CassandraType.support_empty_values = True - # see CASSANDRA-7267 - cassandra.cqltypes._SimpleParameterizedType.deserialize_safe = classmethod(deserialize_safe_collection) - # see CASSANDRA-7267 - cassandra.cqltypes.MapType.deserialize_safe = classmethod(deserialize_safe_map) + + auto_format_udts() + self.empty_lines = 0 self.statement_error = False self.single_statement = single_statement - #see CASSANDRA-7399 - type_for_composites = lambda cls: "'%s'" % cls.cass_parameterized_type_with(cls.subtypes, True) - cassandra.cqltypes.CompositeType.cql_parameterized_type = classmethod(type_for_composites) - cassandra.cqltypes.DynamicCompositeType.cql_parameterized_type = classmethod(type_for_composites) def set_expanded_cql_version(self, ver): ver, vertuple = full_cql_version(ver) http://git-wip-us.apache.org/repos/asf/cassandra/blob/88e05719/lib/cassandra-driver-internal-only-1.1.2.zip ---------------------------------------------------------------------- diff --git a/lib/cassandra-driver-internal-only-1.1.2.zip b/lib/cassandra-driver-internal-only-1.1.2.zip deleted file mode 100644 index cd5181c..0000000 Binary files a/lib/cassandra-driver-internal-only-1.1.2.zip and /dev/null differ http://git-wip-us.apache.org/repos/asf/cassandra/blob/88e05719/lib/cassandra-driver-internal-only-2.1.0b1.post.zip ---------------------------------------------------------------------- diff --git a/lib/cassandra-driver-internal-only-2.1.0b1.post.zip b/lib/cassandra-driver-internal-only-2.1.0b1.post.zip new file mode 100644 index 0000000..d0c0b1a Binary files /dev/null and b/lib/cassandra-driver-internal-only-2.1.0b1.post.zip differ http://git-wip-us.apache.org/repos/asf/cassandra/blob/88e05719/lib/licenses/cassandra-driver-1.0.2.txt ---------------------------------------------------------------------- diff --git a/lib/licenses/cassandra-driver-1.0.2.txt b/lib/licenses/cassandra-driver-1.0.2.txt deleted file mode 100644 index f433b1a..0000000 --- a/lib/licenses/cassandra-driver-1.0.2.txt +++ /dev/null @@ -1,177 +0,0 @@ - - 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 http://git-wip-us.apache.org/repos/asf/cassandra/blob/88e05719/lib/licenses/cassandra-driver-2.1.0b1.post.txt ---------------------------------------------------------------------- diff --git a/lib/licenses/cassandra-driver-2.1.0b1.post.txt b/lib/licenses/cassandra-driver-2.1.0b1.post.txt new file mode 100644 index 0000000..f433b1a --- /dev/null +++ b/lib/licenses/cassandra-driver-2.1.0b1.post.txt @@ -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 http://git-wip-us.apache.org/repos/asf/cassandra/blob/88e05719/lib/licenses/six-1.7.3.txt ---------------------------------------------------------------------- diff --git a/lib/licenses/six-1.7.3.txt b/lib/licenses/six-1.7.3.txt new file mode 100644 index 0000000..d76e024 --- /dev/null +++ b/lib/licenses/six-1.7.3.txt @@ -0,0 +1,18 @@ +Copyright (c) 2010-2014 Benjamin Peterson + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. http://git-wip-us.apache.org/repos/asf/cassandra/blob/88e05719/lib/six-1.7.3-py2.py3-none-any.zip ---------------------------------------------------------------------- diff --git a/lib/six-1.7.3-py2.py3-none-any.zip b/lib/six-1.7.3-py2.py3-none-any.zip new file mode 100644 index 0000000..e077898 Binary files /dev/null and b/lib/six-1.7.3-py2.py3-none-any.zip differ http://git-wip-us.apache.org/repos/asf/cassandra/blob/88e05719/pylib/cqlshlib/formatting.py ---------------------------------------------------------------------- diff --git a/pylib/cqlshlib/formatting.py b/pylib/cqlshlib/formatting.py index 1a504ff..845ffac 100644 --- a/pylib/cqlshlib/formatting.py +++ b/pylib/cqlshlib/formatting.py @@ -110,7 +110,7 @@ def formatter_for(typname): @formatter_for('bytearray') def format_value_blob(val, colormap, **_): - bval = '0x' + ''.join('%02x' % ord(c) for c in val) + bval = '0x' + ''.join('%02x' % c for c in val) return colorme(bval, colormap, 'blob') formatter_for('buffer')(format_value_blob) @@ -215,7 +215,11 @@ def format_simple_collection(val, lbracket, rbracket, encoding, def format_value_list(val, encoding, colormap, time_format, float_precision, nullval, **_): return format_simple_collection(val, '[', ']', encoding, colormap, time_format, float_precision, nullval) -formatter_for('tuple')(format_value_list) + +@formatter_for('tuple') +def format_value_tuple(val, encoding, colormap, time_format, float_precision, nullval, **_): + return format_simple_collection(val, '(', ')', encoding, colormap, + time_format, float_precision, nullval) @formatter_for('set') def format_value_set(val, encoding, colormap, time_format, float_precision, nullval, **_): http://git-wip-us.apache.org/repos/asf/cassandra/blob/88e05719/pylib/cqlshlib/test/test_cqlsh_completion.py ---------------------------------------------------------------------- diff --git a/pylib/cqlshlib/test/test_cqlsh_completion.py b/pylib/cqlshlib/test/test_cqlsh_completion.py index 2da18d7..fc2dad9 100644 --- a/pylib/cqlshlib/test/test_cqlsh_completion.py +++ b/pylib/cqlshlib/test/test_cqlsh_completion.py @@ -177,7 +177,7 @@ class TestCqlshCompletion(CqlshCompletionCase): def test_complete_in_string_literals(self): # would be great if we could get a space after this sort of completion, # but readline really wants to make things difficult for us - self.trycompletions('insert into system."NodeId', 'Info"') + self.trycompletions('insert into system."Index', 'Info"') self.trycompletions('USE "', choices=('system', self.cqlsh.keyspace), other_choices_ok=True) self.trycompletions("create keyspace blah with replication = {'class': 'Sim", http://git-wip-us.apache.org/repos/asf/cassandra/blob/88e05719/pylib/cqlshlib/test/test_cqlsh_output.py ---------------------------------------------------------------------- diff --git a/pylib/cqlshlib/test/test_cqlsh_output.py b/pylib/cqlshlib/test/test_cqlsh_output.py index 6689e4b..6fb4f41 100644 --- a/pylib/cqlshlib/test/test_cqlsh_output.py +++ b/pylib/cqlshlib/test/test_cqlsh_output.py @@ -661,7 +661,7 @@ class TestCqlshOutput(BaseTestCase): AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 - AND read_repair_chance = 0.1 + AND read_repair_chance = 0.0 AND speculative_retry = '99.0PERCENTILE'; """ % quote_name(get_test_keyspace())) http://git-wip-us.apache.org/repos/asf/cassandra/blob/88e05719/pylib/cqlshlib/usertypes.py ---------------------------------------------------------------------- diff --git a/pylib/cqlshlib/usertypes.py b/pylib/cqlshlib/usertypes.py deleted file mode 100644 index 78a7fb0..0000000 --- a/pylib/cqlshlib/usertypes.py +++ /dev/null @@ -1,117 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -from cassandra.marshal import int32_unpack, uint16_unpack -from cassandra.cqltypes import CompositeType -import collections -from formatting import formatter_for, format_value_utype - -class UserType(CompositeType): - typename = "'org.apache.cassandra.db.marshal.UserType'" - - FIELD_LENGTH = 4 - - @classmethod - def apply_parameters(cls, subtypes, names): - newname = subtypes[1].cassname.decode("hex") - field_names = [encoded_name.decode("hex") for encoded_name in names[2:]] - assert len(field_names) == len(subtypes[2:]) - formatter_for(newname)(format_value_utype) - return type(newname, (cls,), {'subtypes': subtypes[2:], - 'cassname': cls.cassname, 'typename': newname, 'fieldnames': field_names}) - - @classmethod - def cql_parameterized_type(cls): - return cls.typename - - @classmethod - def deserialize_safe(cls, byts): - p = 0 - Result = collections.namedtuple(cls.typename, cls.fieldnames) - result = [] - for col_type in cls.subtypes: - if p == len(byts): - break - itemlen = int32_unpack(byts[p:p + cls.FIELD_LENGTH]) - p += cls.FIELD_LENGTH - if itemlen < 0: - result.append(None) - else: - item = byts[p:p + itemlen] - p += itemlen - result.append(col_type.from_binary(item)) - - if len(result) < len(cls.subtypes): - nones = [None] * (len(cls.subtypes) - len(result)) - result = result + nones - - return Result(*result) - -def deserialize_safe_collection(cls, byts): - """ - Temporary work around for CASSANDRA-7267 - """ - subtype, = cls.subtypes - unpack = uint16_unpack - length = 2 - numelements = unpack(byts[:length]) - if numelements == 0 and len(byts) > 2 : - unpack = int32_unpack - length = 4 - numelements = unpack(byts[:length]) - p = length - result = [] - for n in xrange(numelements): - itemlen = unpack(byts[p:p + length]) - p += length - item = byts[p:p + itemlen] - p += itemlen - result.append(subtype.from_binary(item)) - return cls.adapter(result) - -try: - from collections import OrderedDict -except ImportError: # Python <2.7 - from cassandra.util import OrderedDict - -def deserialize_safe_map(cls, byts): - """ - Temporary work around for CASSANDRA-7267 - """ - subkeytype, subvaltype = cls.subtypes - unpack = uint16_unpack - length = 2 - numelements = unpack(byts[:length]) - if numelements == 0 and len(byts) > 2: - unpack = int32_unpack - length = 4 - numelements = unpack(byts[:length]) - - p = length - themap = OrderedDict() - for n in xrange(numelements): - key_len = unpack(byts[p:p + length]) - p += length - keybytes = byts[p:p + key_len] - p += key_len - val_len = unpack(byts[p:p + length]) - p += length - valbytes = byts[p:p + val_len] - p += val_len - key = subkeytype.from_binary(keybytes) - val = subvaltype.from_binary(valbytes) - themap[key] = val - return themap
