Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

rearrange new module structure a bit

to avoid using "from X import *" where easy to do so, and to combine the
translate and cassandra.constants modules, since they accomplished
nearly the same purpose.

removed extraneous __all__ declarations.

clarify name of per-cassandra-version constants.
  • Loading branch information...
commit ff57817dcfcd21105780681a545b085ca591004d 1 parent 81f1892
@thepaul thepaul authored
View
7 telephus/cassandra/constants.py
@@ -1,7 +0,0 @@
-from telephus.cassandra.c07.constants import VERSION as VERSION_07
-from telephus.cassandra.c08.constants import VERSION as VERSION_08
-
-__all__ = ['CASSANDRA_07', 'CASSANDRA_08']
-
-CASSANDRA_07 = VERSION_07
-CASSANDRA_08 = VERSION_08
View
4 telephus/pool.py
@@ -58,9 +58,9 @@
InvalidThriftRequest)
from telephus.cassandra.c08 import Cassandra as Cassandra08
from telephus.cassandra.ttypes import *
-from telephus.cassandra.constants import *
from telephus.client import CassandraClient
-from translate import *
+from telephus.translate import (getAPIVersion, translateArgs,
+ postProcess)
noop = lambda *a, **kw: None
View
5 telephus/protocol.py
@@ -4,10 +4,9 @@
from twisted.internet import defer, reactor
from twisted.internet.error import UserError
from twisted.python import failure
+from telephus import translate
from telephus.cassandra.ttypes import *
-from telephus.cassandra.constants import *
-import telephus.cassandra.c08.Cassandra as Cassandra
-import telephus.translate as translate
+from telephus.cassandra.c08 import Cassandra
from sys import exc_info
class ClientBusy(Exception):
View
16 telephus/translate.py
@@ -1,6 +1,10 @@
-from telephus.cassandra.constants import *
+from telephus.cassandra.c07.constants import VERSION as CASSANDRA_07_VERSION
+from telephus.cassandra.c08.constants import VERSION as CASSANDRA_08_VERSION
-__all__ = ['APIMismatch', 'getAPIVersion', 'translateArgs', 'postProcess']
+supported_versions = (
+ ('0.7', CASSANDRA_07_VERSION),
+ ('0.8', CASSANDRA_08_VERSION),
+)
class APIMismatch(Exception):
pass
@@ -14,10 +18,10 @@ def getAPIVersion(remoteversion):
number should not affect anything noticeable.
"""
r_major, r_minor, r_patch = map(int, remoteversion.split('.'))
- for version in [CASSANDRA_08, CASSANDRA_07]:
- o_major, o_minor, o_patch = map(int, version.split('.'))
+ for cassversion, thriftversion in supported_versions:
+ o_major, o_minor, o_patch = map(int, thriftversion.split('.'))
if (r_major == o_major) and (r_minor >= o_minor):
- return version
+ return thriftversion
msg = 'Cassandra API version %s is not compatible with telephus' % ver
raise APIMismatch(msg)
@@ -25,7 +29,7 @@ def translateArgs(request, api_version):
args = request.args
if request.method == 'system_add_keyspace' or \
request.method == 'system_update_keyspace':
- if api_version == CASSANDRA_07:
+ if api_version == CASSANDRA_07_VERSION:
args = (args[0].to07(),)
else:
args = (args[0].to08(),)
View
4 test/test_cassandraclient.py
@@ -3,7 +3,7 @@
from twisted.internet import defer, reactor, error
from telephus.protocol import ManagedCassandraClientFactory, APIMismatch
from telephus.client import CassandraClient
-from telephus.cassandra import constants
+from telephus import translate
from telephus.cassandra.ttypes import *
import os
@@ -346,7 +346,7 @@ def test_initial_connection_failure(self):
@defer.inlineCallbacks
def test_api_match(self):
- for version in [constants.CASSANDRA_07, constants.CASSANDRA_08, None]:
+ for version in [translate.CASSANDRA_07_VERSION, translate.CASSANDRA_08_VERSION, None]:
cmanager = ManagedCassandraClientFactory(api_version=version)
client = CassandraClient(cmanager)
d = cmanager.deferred
View
4 test/test_cassandraclusterpool.py
@@ -9,7 +9,7 @@
from twisted.python import log
from telephus.pool import (CassandraClusterPool, CassandraPoolReconnectorFactory,
CassandraPoolParticipantClient, TTransport)
-from telephus.cassandra import constants
+from telephus import translate
from telephus.cassandra.c08 import Cassandra
from telephus.cassandra.ttypes import *
@@ -811,7 +811,7 @@ def work_o_tron(optime, numops, n):
starttime = time()
with self.cluster_and_pool(pool_size=1, num_nodes=num_nodes,
- api_version=constants.CASSANDRA_08):
+ api_version=translate.CASSANDRA_08_VERSION):
yield self.make_standard_cfs(ksname)
yield self.insert_dumb_rows(ksname, numkeys=num_keys)
Please sign in to comment.
Something went wrong with that request. Please try again.