http://git-wip-us.apache.org/repos/asf/cassandra/blob/503aec74/pylib/cqlshlib/copyutil.py
----------------------------------------------------------------------
diff --cc pylib/cqlshlib/copyutil.py
index b72b517,85e2678..c9c5829
--- a/pylib/cqlshlib/copyutil.py
+++ b/pylib/cqlshlib/copyutil.py
@@@ -150,37 -129,28 +150,37 @@@ class SendingChannel(object)
      def num_pending(self):
          return self.pending_messages.qsize() if self.pending_messages else 0
  
 -    def recv(self):
 -        with self.rlock:
 -            return self.reader.recv()
 +    def close(self):
 +        self.pipe.close()
 +
 +
 +class SendingChannels(object):
 +    """
 +    A group of one way channels for sending messages.
 +    """
 +    def __init__(self, num_channels):
 +        self.pipes = [OneWayPipe() for _ in xrange(num_channels)]
 +        self.channels = [SendingChannel(p) for p in self.pipes]
 +        self.num_channels = num_channels
  
      def close(self):
 -        self.reader.close()
 -        self.writer.close()
 +        for ch in self.channels:
 +            try:
 +                ch.close()
-             except:
++            except Exception:
 +                pass
  
  
 -class OneWayChannels(object):
 +class ReceivingChannels(object):
      """
 -    A group of one way channels.
 +    A group of one way channels for receiving messages.
      """
      def __init__(self, num_channels):
 -        self.channels = [OneWayChannel() for _ in xrange(num_channels)]
 -        self._readers = [ch.reader for ch in self.channels]
 -        self._rlocks = [ch.rlock for ch in self.channels]
 -        self._rlocks_by_readers = dict([(ch.reader, ch.rlock) for ch in 
self.channels])
 +        self.pipes = [OneWayPipe() for _ in xrange(num_channels)]
 +        self.channels = [ReceivingChannel(p) for p in self.pipes]
 +        self._readers = [p.reader for p in self.pipes]
 +        self._rlocks = [p.rlock for p in self.pipes]
 +        self._rlocks_by_readers = dict([(p.reader, p.rlock) for p in 
self.pipes])
          self.num_channels = num_channels
  
          self.recv = self.recv_select if IS_LINUX else self.recv_polling

http://git-wip-us.apache.org/repos/asf/cassandra/blob/503aec74/pylib/cqlshlib/cql3handling.py
----------------------------------------------------------------------
diff --cc pylib/cqlshlib/cql3handling.py
index 897ee16,012e383..8224ad9
--- a/pylib/cqlshlib/cql3handling.py
+++ b/pylib/cqlshlib/cql3handling.py
@@@ -34,7 -34,8 +34,8 @@@ class UnexpectedTableStructure(UserWarn
      def __str__(self):
          return 'Unexpected table structure; may not translate correctly to 
CQL. ' + self.msg
  
+ 
 -SYSTEM_KEYSPACES = ('system', 'system_traces', 'system_auth')
 +SYSTEM_KEYSPACES = ('system', 'system_traces', 'system_auth', 
'system_distributed')
  NONALTERBALE_KEYSPACES = ('system')
  
  
@@@ -785,10 -691,17 +792,11 @@@ def select_relation_lhs_completer(ctxt
              filterable.add(layout.clustering_key[num].name)
          else:
              break
 -    for cd in layout.columns.values():
 -        if cd.index:
 -            filterable.add(cd.name)
 +    for idx in layout.indexes.itervalues():
 +        filterable.add(idx.index_options["target"])
      return map(maybe_escape_name, filterable)
  
+ 
 -@completer_for('selectClause', 'star')
 -def select_count_star_completer(ctxt, cass):
 -    return ['*']
 -
 -
  explain_completion('selector', 'colname')
  
  syntax_rules += r'''
@@@ -1178,12 -1076,11 +1193,13 @@@ explain_completion('createUserTypeState
  
  @completer_for('createIndexStatement', 'col')
  def create_index_col_completer(ctxt, cass):
 +    """ Return the columns for which an index doesn't exist yet. """
      layout = get_table_meta(ctxt, cass)
 -    colnames = [cd.name for cd in layout.columns.values() if not cd.index]
 +    idx_targets = [idx.index_options["target"] for idx in 
layout.indexes.itervalues()]
 +    colnames = [cd.name for cd in layout.columns.values() if cd.name not in 
idx_targets]
      return map(maybe_escape_name, colnames)
  
+ 
  syntax_rules += r'''
  <dropKeyspaceStatement> ::= "DROP" "KEYSPACE" ("IF" "EXISTS")? 
ksname=<nonSystemKeyspaceName>
                            ;
@@@ -1403,20 -1246,6 +1421,21 @@@ def username_name_completer(ctxt, cass)
      return [maybe_quote(row.values()[0].replace("'", "''")) for row in 
session.execute("LIST USERS")]
  
  
 +@completer_for('rolename', 'role')
 +def rolename_completer(ctxt, cass):
 +    def maybe_quote(name):
 +        if CqlRuleSet.is_valid_cql3_name(name):
 +            return name
 +        return "'%s'" % name
 +
 +    # disable completion for CREATE ROLE.
 +    if ctxt.matched[0][1].upper() == 'CREATE':
 +        return [Hint('<rolename>')]
 +
 +    session = cass.session
 +    return [maybe_quote(row[0].replace("'", "''")) for row in 
session.execute("LIST ROLES")]
 +
++
  syntax_rules += r'''
  <createTriggerStatement> ::= "CREATE" "TRIGGER" ( "IF" "NOT" "EXISTS" )? 
<cident>
                                 "ON" cf=<columnFamilyName> "USING" 
class=<stringLiteral>

http://git-wip-us.apache.org/repos/asf/cassandra/blob/503aec74/pylib/cqlshlib/displaying.py
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/503aec74/pylib/cqlshlib/formatting.py
----------------------------------------------------------------------
diff --cc pylib/cqlshlib/formatting.py
index dcd08da,eac1810..f88fc5d
--- a/pylib/cqlshlib/formatting.py
+++ b/pylib/cqlshlib/formatting.py
@@@ -53,7 -50,9 +54,8 @@@ def _make_turn_bits_red_f(color1, color
          return color1 + txt + color2
      return _turn_bits_red
  
+ 
  default_null_placeholder = 'null'
 -default_time_format = ''
  default_float_precision = 3
  default_colormap = DEFAULT_VALUE_COLORS
  empty_colormap = defaultdict(lambda: '')
@@@ -97,24 -96,7 +99,25 @@@ def color_text(bval, colormap, displayw
          displaywidth -= bval.count(r'\\')
      return FormattedValue(bval, coloredval, displaywidth)
  
+ 
 +DEFAULT_NANOTIME_FORMAT = '%H:%M:%S.%N'
 +DEFAULT_DATE_FORMAT = '%Y-%m-%d'
 +DEFAULT_TIMESTAMP_FORMAT = '%Y-%m-%d %H:%M:%S%z'
 +
 +if platform.system() == 'Windows':
 +    DEFAULT_TIME_FORMAT = '%Y-%m-%d %H:%M:%S %Z'
 +
 +
 +class DateTimeFormat():
 +
 +    def __init__(self, timestamp_format=DEFAULT_TIMESTAMP_FORMAT, 
date_format=DEFAULT_DATE_FORMAT,
 +                 nanotime_format=DEFAULT_NANOTIME_FORMAT, timezone=None):
 +        self.timestamp_format = timestamp_format
 +        self.date_format = date_format
 +        self.nanotime_format = nanotime_format
 +        self.timezone = timezone
 +
 +
  def format_value_default(val, colormap, **_):
      val = str(val)
      escapedval = val.replace('\\', '\\\\')
@@@ -146,8 -129,10 +150,10 @@@ def formatter_for(typname)
  
  @formatter_for('bytearray')
  def format_value_blob(val, colormap, **_):
 -    bval = '0x' + binascii.hexlify(str(val))
 +    bval = '0x' + binascii.hexlify(val)
      return colorme(bval, colormap, 'blob')
+ 
+ 
  formatter_for('buffer')(format_value_blob)
  
  
@@@ -311,14 -290,18 +320,16 @@@ def format_value_tuple(val, encoding, c
  
  
  @formatter_for('set')
 -def format_value_set(val, encoding, colormap, time_format, float_precision, 
nullval,
 +def format_value_set(val, encoding, colormap, date_time_format, 
float_precision, nullval,
                       decimal_sep, thousands_sep, boolean_styles, **_):
      return format_simple_collection(sorted(val), '{', '}', encoding, colormap,
 -                                    time_format, float_precision, nullval,
 +                                    date_time_format, float_precision, 
nullval,
                                      decimal_sep, thousands_sep, 
boolean_styles)
+ 
+ 
  formatter_for('frozenset')(format_value_set)
 -# This code is used by cqlsh (bundled driver version 2.7.2 using sortedset),
 -# and the dtests, which use whichever driver on the machine, i.e. 3.0.0 
(SortedSet)
 -formatter_for('SortedSet')(format_value_set)
  formatter_for('sortedset')(format_value_set)
 +formatter_for('SortedSet')(format_value_set)
  
  
  @formatter_for('dict')


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to