Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show connect message only in verbose mode #231

Merged
merged 1 commit into from
Oct 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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