Skip to content

Commit

Permalink
show connect message only in verbose mode
Browse files Browse the repository at this point in the history
this does not require to connect twice on startup any more
  • Loading branch information
chaudum committed Oct 16, 2017
1 parent 471e2d2 commit e231bb7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Expand Up @@ -5,6 +5,10 @@ Changes for crash
Unreleased
==========

- Do not show connect message on startup by default but only when starting
crash in verbose mode. This prevents the programme from printing the message
to stdout when using the command mode or executing ``--sysinfo``.

- Added support for pasting and executing multiple statements at once.

2017/10/11 0.22.2
Expand Down
19 changes: 14 additions & 5 deletions src/crate/crash/command.py
Expand Up @@ -313,6 +313,9 @@ def _connect(self, server):
""" connect to the given server, e.g.: \connect localhost:4200 """
self.last_connected_servers = server
self._do_connect()
self._verify_connection(verbose=True)

def _verify_connection(self, verbose=False):
results = []
failed = 0
client = self.connection.client
Expand All @@ -324,14 +327,17 @@ def _connect(self, server):
results.append([server, None, '0.0.0', False, e.message])
else:
results.append(infos + (True, 'OK', ))
self.pprint(results,
['server_url', 'node_name', 'version', 'connected', 'message'])

if verbose:
cols = ['server_url', 'node_name', 'version', 'connected', 'message']
self.pprint(results, cols)

if failed == len(results):
self.logger.critical('CONNECT ERROR')
else:
self.logger.info('CONNECT OK')
# Execute cluster/node checks only in verbose mode
if self.error_trace:
self.logger.info('CONNECT OK')
if verbose:
SysInfoCommand.CLUSTER_INFO['information_schema_query'] = \
get_information_schema_query(self.connection.lowest_server_version)
# check for failing node and cluster checks
Expand Down Expand Up @@ -488,9 +494,12 @@ def main():
cmd = _create_cmd(crate_hosts, error_trace, output_writer, is_tty, args)
except (ProgrammingError, LocationParseError) as e:
printer.warn(str(e))

cmd._verify_connection(verbose=error_trace)

if not cmd.is_conn_available():
sys.exit(1)

cmd._connect(crate_hosts)
done = False
stdin_data = get_stdin()
if args.sysinfo:
Expand Down

0 comments on commit e231bb7

Please sign in to comment.