Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete use of 'six' for Python 2.7 compatibility #759

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ small Cassandra cluster on a local box. It is meant for testing a Cassandra clus
New to Python development?
--------------------------
Python has moved on since CCM started development. `pip` is the new `easy_install`,
Python 3 is the new 2.7, and pyenv and virtualenv are strongly recommended for managing
multiple Python versions and dependencies for specific Python applications.
Use pyenv and virtualenv for managing multiple Python versions and dependencies for specific
Python applications.

A typical MacOS setup would be to install [Homebrew](https://docs.brew.sh/Installation),
then `brew install pyenv` to manage Python versions and then use virtualenv to
Expand Down Expand Up @@ -77,7 +77,7 @@ Also don't forget to disable `AirPlay Receiver` on MacOS which also listens on p
Requirements
------------

- A working python installation (tested to work with python 2.7).
- A working python installation
- See `requirements.txt` for runtime requirements
- `mock` and `pytest` for tests
- ant (http://ant.apache.org/, on Mac OS X, `brew install ant`)
Expand Down
30 changes: 12 additions & 18 deletions ccmlib/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,10 @@
from distutils.version import LooseVersion #pylint: disable=import-error, no-name-in-module

import yaml
from six import print_

from ccmlib import common, extension, repository
from ccmlib.node import Node, NodeError, TimeoutError
from six.moves import xrange
try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse

from urllib.parse import urlparse

DEFAULT_CLUSTER_WAIT_TIMEOUT_IN_SECS = int(os.environ.get('CCM_CLUSTER_START_DEFAULT_TIMEOUT', 120))

Expand Down Expand Up @@ -280,13 +274,13 @@ def populate(self, nodes, debug=False, tokens=None, use_vnodes=None, ipprefix='1
for c in nodes:
i = i + 1
node_count = node_count + c
for x in xrange(0, c):
for x in range(0, c):
dcs.append('dc%d' % i)

if node_count < 1:
raise common.ArgumentError('invalid node count %s' % nodes)

for i in xrange(1, node_count + 1):
for i in range(1, node_count + 1):
if 'node%s' % i in list(self.nodes.values()):
raise common.ArgumentError('Cannot create existing node node%s' % i)

Expand All @@ -296,7 +290,7 @@ def populate(self, nodes, debug=False, tokens=None, use_vnodes=None, ipprefix='1
# this saves time, as allocating tokens during first start is slow and non-concurrent
if self.can_generate_tokens() and not 'CASSANDRA_TOKEN_PREGENERATION_DISABLED' in self._environment_variables:
if len(dcs) <= 1:
for x in xrange(0, node_count):
for x in range(0, node_count):
dcs.append('dc1')

tokens = self.generated_tokens(dcs)
Expand All @@ -310,7 +304,7 @@ def populate(self, nodes, debug=False, tokens=None, use_vnodes=None, ipprefix='1
if not ipformat:
ipformat = ipprefix + "%d"

for i in xrange(1, node_count + 1):
for i in range(1, node_count + 1):
tk = None
if tokens is not None and i - 1 < len(tokens):
tk = tokens[i - 1]
Expand Down Expand Up @@ -353,7 +347,7 @@ def create_node(self, name, auto_bootstrap, thrift_interface, storage_interface,

def balanced_tokens(self, node_count):
if self.cassandra_version() >= '1.2' and (not self.partitioner or 'Murmur3' in self.partitioner):
ptokens = [(i * (2 ** 64 // node_count)) for i in xrange(0, node_count)]
ptokens = [(i * (2 ** 64 // node_count)) for i in range(0, node_count)]
return [int(t - 2 ** 63) for t in ptokens]
return [int(i * (2 ** 127 // node_count)) for i in range(0, node_count)]

Expand Down Expand Up @@ -485,15 +479,15 @@ def get_seeds(self):

def show(self, verbose):
msg = "Cluster: '{}'".format(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 @@ -630,7 +624,7 @@ def stress(self, stress_options):
stress = common.get_stress_bin(self.get_install_dir())
livenodes = [node.network_interfaces['binary'] for node in list(self.nodes.values()) if node.is_live()]
if len(livenodes) == 0:
print_('No live node')
print('No live node')
return

def live_node_ips_joined():
Expand Down Expand Up @@ -858,7 +852,7 @@ def show_logs(self, selected_nodes_names=None):
selected_nodes_names = []

if len(self.nodes) == 0:
print_("There are no nodes in this cluster yet.")
print("There are no nodes in this cluster yet.")
return

nodes = sorted(list(self.nodes.values()), key=lambda node: node.name)
Expand Down
Loading