You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2011/11/11 23:32:17 UTC
svn commit: r1201080 - in /cassandra/branches/cassandra-1.0: CHANGES.txt
bin/cqlsh
Author: jbellis
Date: Fri Nov 11 22:32:17 2011
New Revision: 1201080
URL: http://svn.apache.org/viewvc?rev=1201080&view=rev
Log:
don't use cqlsh color on Windows
patch by Paul Cannon; reviewed by jbellis for for CASSANDRA-3131
Modified:
cassandra/branches/cassandra-1.0/CHANGES.txt
cassandra/branches/cassandra-1.0/bin/cqlsh
Modified: cassandra/branches/cassandra-1.0/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/CHANGES.txt?rev=1201080&r1=1201079&r2=1201080&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/CHANGES.txt (original)
+++ cassandra/branches/cassandra-1.0/CHANGES.txt Fri Nov 11 22:32:17 2011
@@ -1,6 +1,6 @@
1.0.3
* fix invalidate-related test failures (CASSANDRA-3437)
- * add next-gen cqlsh to bin/
+ * add next-gen cqlsh to bin/ (CASSANDRA-3188, 3131)
* (CQL) fix handling of rows with no columns (CASSANDRA-3424, 3473)
* fix querying supercolumns by name returning only a subset of
subcolumns or old subcolumn versions (CASSANDRA-3446)
Modified: cassandra/branches/cassandra-1.0/bin/cqlsh
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/bin/cqlsh?rev=1201080&r1=1201079&r2=1201080&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/bin/cqlsh (original)
+++ cassandra/branches/cassandra-1.0/bin/cqlsh Fri Nov 11 22:32:17 2011
@@ -49,10 +49,10 @@ except ImportError:
try:
import cql
-except ImportError:
+except ImportError, e:
sys.stderr.write("\nPython CQL driver not installed, or not on PYTHONPATH.\n")
sys.stderr.write('You might try "easy_install cql".\n\n')
- sys.exit(1)
+ sys.exit(str(e))
import cql.decoders
from cql.cursor import _COUNT_DESCRIPTION, _VOID_DESCRIPTION
@@ -211,19 +211,17 @@ class Shell(cmd.Cmd):
self.current_keyspace = None
- if sys.stdin.isatty():
- self.prompt = Shell.default_prompt
- else:
- self.prompt = ""
-
self.statement = StringIO()
self.color = color
self.in_comment = False
self.schema_overrides = {}
- if os.isatty(0):
+ if sys.stdin.isatty():
+ self.prompt = Shell.default_prompt
self.report_connection()
self.printout('Use HELP for help.')
+ else:
+ self.prompt = ""
def report_connection(self):
self.show_host()
@@ -1421,6 +1419,23 @@ def option_with_default(cparser_getter,
except ConfigParser.Error:
return default
+def should_use_color():
+ if not sys.stdin.isatty():
+ return False
+ if os.environ.get('TERM', 'dumb') == 'dumb':
+ return False
+ try:
+ import subprocess
+ p = subprocess.Popen(['tput', 'colors'], stdout=subprocess.PIPE)
+ stdout, _ = p.communicate()
+ if int(stdout.strip()) < 8:
+ return False
+ except (OSError, ImportError):
+ # oh well, we tried. at least we know there's a $TERM and it's
+ # not "dumb".
+ pass
+ return True
+
def read_options(cmdlineargs, environment):
configs = ConfigParser.SafeConfigParser()
configs.read(CONFIG_FILE)
@@ -1432,7 +1447,7 @@ def read_options(cmdlineargs, environmen
optvalues.color = option_with_default(configs.getboolean, 'ui', 'color')
if optvalues.color is None:
# default yes if tty
- optvalues.color = bool(os.isatty(0))
+ optvalues.color = should_use_color()
optvalues.debug = False
(options, arguments) = parser.parse_args(cmdlineargs, values=optvalues)