Skip to content

Commit

Permalink
treewide: do not use six module
Browse files Browse the repository at this point in the history
* now that we've dropped python2 support, there is no need to
  use six anymore. following command is used to remove six
  ```
  find . -type f -name "*.py" -exec sed -i -e '/from six.* import/d' -e 's/ print_(/ print(/g' {} +
  find . -type f -name "ccm" -exec sed -i -e '/from six.* import/d' -e 's/ print_(/ print(/g' {} +
  ```
* `iteritems(x)` calls are replaced with `x.items()`
* itertools.zip_longest() is used instead of the one from six
* s/string_types/str/
* import io for `StringIO`
* import urllib when urllib is used
* README.md: do not mention six anymore.
* setup.py, tox.ini: drop six

Fixes #432
Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov authored and fruch committed Mar 25, 2023
1 parent 42dca88 commit 2703174
Show file tree
Hide file tree
Showing 18 changed files with 168 additions and 187 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Requirements

- A working python installation (tested to work with python 3.11).
- pyYAML (http://pyyaml.org/ -- `sudo easy_install pyYaml`)
- six (https://pypi.python.org/pypi/six -- `sudo easy_install six`)
- ant (http://ant.apache.org/, on Mac OS X, `brew install ant`)
- psutil (https://pypi.python.org/pypi/psutil)
- Java (which version depends on the version of Cassandra you plan to use. If
Expand Down
27 changes: 13 additions & 14 deletions ccm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import sys

from six import print_

from ccmlib import common
from ccmlib.cmds import command, cluster_cmds, node_cmds
Expand All @@ -20,31 +19,31 @@ def get_command(kind, cmd):


def print_global_usage():
print_("Usage:")
print_(" ccm <cluster_cmd> [options]")
print_(" ccm <node_name> <node_cmd> [options]")
print_("")
print_("Where <cluster_cmd> is one of")
print("Usage:")
print(" ccm <cluster_cmd> [options]")
print(" ccm <node_name> <node_cmd> [options]")
print("")
print("Where <cluster_cmd> is one of")
for cmd_name in cluster_cmds.cluster_cmds():
cmd = get_command("cluster", cmd_name)
if not cmd:
print_("Internal error, unknown command {0}".format(cmd_name))
print("Internal error, unknown command {0}".format(cmd_name))
exit(1)
print_(" {0:14} {1}".format(cmd_name, cmd.description()))
print_("or <node_name> is the name of a node of the current cluster and <node_cmd> is one of")
print(" {0:14} {1}".format(cmd_name, cmd.description()))
print("or <node_name> is the name of a node of the current cluster and <node_cmd> is one of")
for cmd_name in node_cmds.node_cmds():
cmd = get_command("node", cmd_name)
if not cmd:
print_("Internal error, unknown command {0}".format(cmd_name))
print("Internal error, unknown command {0}".format(cmd_name))
exit(1)
print_(" {0:14} {1}".format(cmd_name, cmd.description()))
print(" {0:14} {1}".format(cmd_name, cmd.description()))
exit(1)


common.check_win_requirements()

if len(sys.argv) <= 1:
print_("Missing arguments")
print("Missing arguments")
print_global_usage()

arg1 = sys.argv[1].lower()
Expand All @@ -55,7 +54,7 @@ if arg1 in cluster_cmds.cluster_cmds():
cmd_args = sys.argv[2:]
else:
if len(sys.argv) <= 2:
print_("Missing arguments")
print("Missing arguments")
print_global_usage()
kind = 'node'
node = arg1
Expand All @@ -64,7 +63,7 @@ else:

cmd = get_command(kind, cmd)
if not cmd:
print_("Unknown node or command: {0}".format(arg1))
print("Unknown node or command: {0}".format(arg1))
exit(1)

parser = cmd.get_parser()
Expand Down
14 changes: 6 additions & 8 deletions ccmlib/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from concurrent.futures import ThreadPoolExecutor

import yaml
from six import iteritems, print_
from six.moves import xrange

from ccmlib import common, repository
from ccmlib.node import Node, NodeError
Expand Down Expand Up @@ -409,15 +407,15 @@ def get_seeds(self, node=None):

def show(self, verbose):
msg = f"Cluster: '{self.name}'"
print_(msg)
print_('-' * len(msg))
print(msg)
print('-' * len(msg))
if len(list(self.nodes.values())) == 0:
print_("No node in this cluster yet")
print("No node in this cluster yet")
return
for node in list(self.nodes.values()):
if (verbose):
node.show(show_cluster=False)
print_("")
print("")
else:
node.show(only_status=True)

Expand Down Expand Up @@ -525,7 +523,7 @@ def nodetool(self, nodetool_cmd):
def stress(self, stress_options):
livenodes = [node.network_interfaces['storage'][0] for node in list(self.nodes.values()) if node.is_live()]
if len(livenodes) == 0:
print_("No live node")
print("No live node")
return
self.nodelist()[0].stress(stress_options=stress_options + ['-node', ','.join(livenodes)] )
return self
Expand All @@ -539,7 +537,7 @@ def run_cli(self, cmds=None, show_output=False, cli_options=None):

def set_configuration_options(self, values=None, batch_commitlog=None):
if values is not None:
for k, v in iteritems(values):
for k, v in values.items():
self._config_options[k] = v
if batch_commitlog is not None:
if batch_commitlog:
Expand Down
Loading

0 comments on commit 2703174

Please sign in to comment.