cqlsh: use python-cql and thrift bindings from lib ..if possible.
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b6344887 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b6344887 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b6344887 Branch: refs/heads/trunk Commit: b6344887c253619bd5fb0b41369d399d5f4e67b7 Parents: 44406f1 Author: paul cannon <[email protected]> Authored: Wed Jan 25 23:55:30 2012 -0600 Committer: Eric Evans <[email protected]> Committed: Sun Jan 29 19:01:25 2012 -0600 ---------------------------------------------------------------------- bin/cqlsh | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/b6344887/bin/cqlsh ---------------------------------------------------------------------- diff --git a/bin/cqlsh b/bin/cqlsh index 5d68369..c30bc58 100755 --- a/bin/cqlsh +++ b/bin/cqlsh @@ -34,15 +34,14 @@ from __future__ import with_statement description = "CQL Shell for Apache Cassandra" version = "2.0.0" -from collections import defaultdict from StringIO import StringIO from itertools import groupby from contextlib import contextmanager +from glob import glob import cmd import sys import os -import string import time import optparse import ConfigParser @@ -64,6 +63,21 @@ try: except ImportError: readline = None +CQL_LIB_PREFIX = 'cql-internal-only-' +THRIFT_LIB_PREFIX = 'thrift-python-internal-only-' + +# use bundled libs for python-cql and thrift, if available +ziplibdir = os.path.join(os.path.dirname(__file__), '..', 'lib') +cql_zips = glob(os.path.join(ziplibdir, CQL_LIB_PREFIX + '*.zip')) +if cql_zips: + cql_zip = cql_zips[0] + ver = os.path.splitext(os.path.basename(cql_zip))[0][len(CQL_LIB_PREFIX):] + sys.path.insert(0, os.path.join(cql_zip, 'cql-' + ver)) +thrift_zips = glob(os.path.join(ziplibdir, THRIFT_LIB_PREFIX + '*.zip')) +if thrift_zips: + thrift_zip = thrift_zips[0] + sys.path.insert(0, thrift_zip) + try: import cql except ImportError, e:
