Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .build/build-resolver.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
<get src="${artifact.python.pypi}/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl" dest="${local.repository}/org/apache/cassandra/deps/six-1.12.0-py2.py3-none-any.zip" usetimestamp="true" quiet="true" skipexisting="true"/>
<get src="${artifact.python.pypi}/20/f4/c0584a25144ce20bfcf1aecd041768b8c762c1eb0aa77502a3f0baa83f11/wcwidth-0.2.6-py2.py3-none-any.whl" dest="${local.repository}/org/apache/cassandra/deps/wcwidth-0.2.6-py2.py3-none-any.zip" usetimestamp="true" quiet="true" skipexisting="true"/>
<get src="${artifact.python.pypi}/37/b2/ef1124540ee2c0b417be8d0f74667957e6aa084a3f26621aa67e2e77f3fb/pure_sasl-0.6.2-py2-none-any.whl" dest="${local.repository}/org/apache/cassandra/deps/pure_sasl-0.6.2-py2-none-any.zip" usetimestamp="true" quiet="true" skipexisting="true"/>
<get src="${artifact.python.pypi}/1f/ab/b10cee56269ae150763f3f83b3e9305a11f42f50b3dcd58eeb8f7988f0bb/pyasyncore-1.0.5-py3-none-any.whl" dest="${local.repository}/org/apache/cassandra/deps/pyasyncore-1.0.5-py3-none-any.zip" usetimestamp="true" quiet="true" skipexisting="true"/>

<!-- apache/cassandra/lib -->
<get src="${lib.download.base.url}/lib/geomet-0.1.0.zip" dest="${local.repository}/org/apache/cassandra/deps/geomet-0.1.0.zip" usetimestamp="true" quiet="true" skipexisting="true"/>
Expand Down Expand Up @@ -233,10 +234,10 @@

<copy todir="${build.lib}" quiet="true">
<file file="${local.repository}/org/apache/cassandra/deps/futures-2.1.6-py2.py3-none-any.zip"/>
<file file="${local.repository}/org/apache/cassandra/deps/six-1.12.0-py2.py3-none-any.zip"/>
<file file="${local.repository}/org/apache/cassandra/deps/geomet-0.1.0.zip"/>
<file file="${local.repository}/org/apache/cassandra/deps/wcwidth-0.2.6-py2.py3-none-any.zip"/>
<file file="${local.repository}/org/apache/cassandra/deps/pure_sasl-0.6.2-py2-none-any.zip"/>
<file file="${local.repository}/org/apache/cassandra/deps/pyasyncore-1.0.5-py3-none-any.zip"/>
</copy>
<copy todir="${build.lib}/sigar-bin/" quiet="true">
<file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-amd64-freebsd-6.so"/>
Expand Down
6 changes: 4 additions & 2 deletions bin/cqlsh
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ is_supported_version() {
version=$1
major_version="${version%.*}"
minor_version="${version#*.}"
# python3.6+ is supported. python2.7 is deprecated but still compatible.
if [ "$major_version" = 3 ] && [ "$minor_version" -ge 6 ] || [ "$version" = "2.7" ]; then
# python 3.8-3.11 are supported
if [ "$major_version" = 3 ] && [ "$minor_version" -ge 8 ] && [ "$minor_version" -le 13 ]; then
echo "supported"
else
echo "unsupported"
Expand All @@ -79,6 +79,8 @@ run_if_supported_version() {
if [ "$(is_supported_version "$version")" = "supported" ]; then
exec "$interpreter" "$($interpreter -c "import os; print(os.path.dirname(os.path.realpath('$0')))")/cqlsh.py" "$@"
exit
else
echo "Warning: unsupported version of Python, required 3.6-3.13 but found" "$version" >&2
fi
fi
}
Expand Down
46 changes: 19 additions & 27 deletions bin/cqlsh.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
Expand Down Expand Up @@ -34,8 +34,8 @@
from glob import glob
from uuid import UUID

if sys.version_info < (3, 6) and sys.version_info[0:2] != (2, 7):
sys.exit("\ncqlsh requires Python 3.6+ or Python 2.7 (deprecated)\n")
if sys.version_info < (3, 6) or sys.version_info >= (3, 14):
sys.exit("\ncqlsh requires Python 3.6-3.13\n")

# see CASSANDRA-10428
if platform.python_implementation().startswith('Jython'):
Expand Down Expand Up @@ -117,19 +117,15 @@ def find_zip(libprefix):
sys.path.insert(0, os.path.join(cql_zip, 'cassandra-driver-' + ver))

# the driver needs dependencies
third_parties = ('futures-', 'six-', 'geomet-', 'pure_sasl-', 'datastax_db_*-')
third_parties = ('geomet-', 'pure_sasl-', 'datastax_db_*-', 'pyasyncore-')

for lib in third_parties:
lib_zip = find_zip(lib)
if lib_zip:
sys.path.insert(0, lib_zip)

# We cannot import six until we add its location to sys.path so the Python
# interpreter can find it. Do not move this to the top.
import six

from six.moves import configparser, input
from six import StringIO, ensure_text, ensure_str
import configparser
from io import StringIO

warnings.filterwarnings("ignore", r".*blist.*")
try:
Expand Down Expand Up @@ -369,7 +365,7 @@ def __repr__(self):


def maybe_ensure_text(val):
return ensure_text(val) if val else val
return str(val) if val else val


class FormatError(DecodeError):
Expand Down Expand Up @@ -434,7 +430,7 @@ def deserialize_date_fallback_int(byts, protocol_version):


class Shell(cmd.Cmd):
custom_prompt = ensure_text(os.getenv('CQLSH_PROMPT', ''))
custom_prompt = os.getenv('CQLSH_PROMPT', '')
if custom_prompt != '':
custom_prompt += "\n"
default_prompt = custom_prompt + "cqlsh> "
Expand Down Expand Up @@ -915,15 +911,14 @@ def prepare_loop(self):

def get_input_line(self, prompt=''):
if self.tty:
self.lastcmd = input(ensure_str(prompt))
line = ensure_text(self.lastcmd) + '\n'
self.lastcmd = input(str(prompt))
line = self.lastcmd + '\n'
else:
self.lastcmd = ensure_text(self.stdin.readline())
self.lastcmd = self.stdin.readline()
line = self.lastcmd
if not len(line):
raise EOFError
self.lineno += 1
line = ensure_text(line)
return line

def use_stdin_reader(self, until='', prompt=''):
Expand Down Expand Up @@ -984,7 +979,6 @@ def onecmd(self, statementtext):
Returns true if the statement is complete and was handled (meaning it
can be reset).
"""
statementtext = ensure_text(statementtext)
statementtext = self.strip_comment_blocks(statementtext)
try:
statements, endtoken_escaped = cqlruleset.cql_split_statements(statementtext)
Expand Down Expand Up @@ -1030,7 +1024,7 @@ def handle_statement(self, tokens, srcstr):
if readline is not None:
nl_count = srcstr.count("\n")

new_hist = ensure_str(srcstr.replace("\n", " ").rstrip())
new_hist = srcstr.replace("\n", " ").rstrip()

if nl_count > 1 and self.last_hist != new_hist:
readline.add_history(new_hist)
Expand Down Expand Up @@ -1081,7 +1075,6 @@ def do_select(self, parsed):
self.tracing_style = tracing_was_enabled

def perform_statement(self, statement):
statement = ensure_text(statement)

stmt = SimpleStatement(statement, consistency_level=self.consistency_level, serial_consistency_level=self.serial_consistency_level, fetch_size=self.page_size if self.use_paging else None)
success, future = self.perform_simple_statement(stmt)
Expand Down Expand Up @@ -1133,7 +1126,7 @@ def perform_simple_statement(self, statement):
return False, None

def print_cql_error(err):
err_msg = ensure_text(err.message if hasattr(err, 'message') else str(err))
err_msg = err.message if hasattr(err, 'message') else str(err)
self.printerr(str(err.__class__.__name__) + ": " + err_msg)

future = self.session.execute_async(statement, trace=self.tracing_style in ["full", "compact"])
Expand Down Expand Up @@ -1482,7 +1475,7 @@ def describe_keyspaces(self, rows):
"""
Print the output for a DESCRIBE KEYSPACES query
"""
names = [ensure_str(r['name']) for r in rows]
names = [r['name'] for r in rows]

print('')
cmd.Cmd.columnize(self, names)
Expand All @@ -1502,7 +1495,7 @@ def describe_list(self, rows):
keyspace = row['keyspace_name']
names = list()

names.append(ensure_str(row['name']))
names.append(str(row['name']))

if keyspace is not None:
self.print_keyspace_element_names(keyspace, names)
Expand Down Expand Up @@ -1644,7 +1637,7 @@ def do_copy(self, parsed):
if fname is not None:
fname = self.cql_unprotect_value(fname)

copyoptnames = list(map(six.text_type.lower, parsed.get_binding('optnames', ())))
copyoptnames = list(map(str.lower, parsed.get_binding('optnames', ())))
copyoptvals = list(map(self.cql_unprotect_value, parsed.get_binding('optvals', ())))
opts = dict(list(zip(copyoptnames, copyoptvals)))

Expand Down Expand Up @@ -2105,11 +2098,10 @@ def writeresult(self, text, color=None, newline=True, out=None):
out = self.query_out

# convert Exceptions, etc to text
if not isinstance(text, six.text_type):
text = "{}".format(text)
if not isinstance(text, str):
text = str(text)

to_write = self.applycolor(text, color) + ('\n' if newline else '')
to_write = ensure_str(to_write)
out.write(to_write)

def flush_output(self):
Expand Down Expand Up @@ -2227,7 +2219,7 @@ def should_use_color():


def read_options(cmdlineargs, environment):
configs = configparser.SafeConfigParser() if sys.version_info < (3, 2) else configparser.ConfigParser()
configs = configparser.ConfigParser()
configs.read(CONFIG_FILE)

rawconfigs = configparser.RawConfigParser()
Expand Down
Binary file not shown.
Binary file added lib/cassandra-driver-internal-only-3.30.0.zip
Binary file not shown.
3 changes: 1 addition & 2 deletions pylib/cassandra-cqlsh-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ else
cython_suffix="no-cython"
fi

# re-use when possible the pre-installed virtualenv found in the cassandra-ubuntu2004_test docker image
# re-use when possible the pre-installed virtualenv found in the cassandra-ubuntu-test docker image
virtualenv-clone ${BUILD_HOME}/${cython_suffix}/python${python_version} ${BUILD_DIR}/venv || virtualenv --python=python${python_version} ${BUILD_DIR}/venv
source ${BUILD_DIR}/venv/bin/activate

if [ "$cython" = "yes" ]; then
pip install "Cython>=0.29.15,<3.0"
Expand Down
Loading
Loading