cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [04/12] git commit: Handle KeyboardInterrupt properly in cqlsh
Date Tue, 29 Jul 2014 18:59:28 GMT
Handle KeyboardInterrupt properly in cqlsh

Patch by Jordon Pittier, reviewed by brandonwilliams for CASSANDRA-5481


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/249bbfc3
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/249bbfc3
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/249bbfc3

Branch: refs/heads/trunk
Commit: 249bbfc3b205d934764e5b05e955378f78c28480
Parents: 192596a
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Tue Jul 29 13:57:42 2014 -0500
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Tue Jul 29 13:57:42 2014 -0500

----------------------------------------------------------------------
 bin/cqlsh | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/249bbfc3/bin/cqlsh
----------------------------------------------------------------------
diff --git a/bin/cqlsh b/bin/cqlsh
index bb0ffdf..d2a503d 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -504,15 +504,9 @@ class Shell(cmd.Cmd):
             self.conn = use_conn
         else:
             transport = transport_factory(hostname, port, os.environ, CONFIG_FILE)
-            self.conn = cql.connect(hostname, port, user=username, password=password,
-                                    cql_version=cqlver, transport=transport)
+            self.conn = cql.connect(hostname, port, keyspace=keyspace, user=username, 
+                                    password=password, cql_version=cqlver, transport=transport)
         self.set_expanded_cql_version(cqlver)
-        # we could set the keyspace through cql.connect(), but as of 1.0.10,
-        # it doesn't quote the keyspace for USE :(
-        if keyspace is not None:
-            tempcurs = self.conn.cursor()
-            tempcurs.execute('USE %s;' % self.cql_protect_name(keyspace))
-            tempcurs.close()
         self.cursor = self.conn.cursor()
         self.get_connection_versions()
 
@@ -1056,6 +1050,16 @@ class Shell(cmd.Cmd):
             except CQL_ERRORS, err:
                 self.printerr(str(err))
                 return False
+            except KeyboardInterrupt:
+                self.cursor.close()
+                self.conn.terminate_connection()
+                transport = self.transport_factory(self.hostname, self.port,
+                                                   os.environ, CONFIG_FILE)
+                self.conn = cql.connect(self.hostname, self.port, keyspace=self.keyspace,
+                                        user=self.username, password=self.password,
+                                        cql_version=self.cql_version, transport=transport)
+                self.cursor = self.conn.cursor()
+                return False                
             except Exception, err:
                 import traceback
                 self.printerr(traceback.format_exc())


Mime
View raw message