def ping(ctx, access_token): # noqa: D301 """Check connection to REANA server. The `ping` command allows to test connection to REANA server. Examples: \n \t $ reana-client ping """ try: from reana_client.api.client import ping as rs_ping from reana_client.utils import get_api_url logging.info('Connecting to {0}'.format(get_api_url())) response = rs_ping(access_token) msg_color = 'red' if response.get('error') else 'green' click.echo( click.style('REANA server: {0}\n' 'Authenticated as: {1} <{2}>\n' 'Status: {3}'.format(get_api_url(), response.get('full_name') or '', response.get('email'), response.get('status')), fg=msg_color)) logging.debug('Server response:\n{}'.format(response)) except Exception as e: logging.debug(traceback.format_exc()) logging.debug(str(e)) error_msg = ('Could not connect to the selected REANA cluster ' 'server at {0}:\n{1}'.format(get_api_url(), e)) click.echo(click.style(error_msg, fg='red'), err=True) ctx.exit(1)
def ping(ctx): # noqa: D301 """Check connection to REANA server. The `ping` command allows to test connection to REANA server. Examples: \n \t reana-client ping """ try: logging.info('Connecting to {0}'.format( current_rs_api_client.swagger_spec.api_url)) response = rs_ping() click.echo( click.style('Connected to {0} - Server is running.'.format( current_rs_api_client.swagger_spec.api_url), fg='green')) logging.debug('Server response:\n{}'.format(response)) except MissingAPIClientConfiguration as e: click.secho('REANA client is not connected to any REANA cluster.', fg='red') except Exception as e: logging.debug(traceback.format_exc()) logging.debug(str(e)) click.echo(click.style('Could not connect to the selected ' 'REANA cluster server at {0}.'.format( current_rs_api_client.swagger_spec.api_url), fg='red'), err=True)
def ping(ctx, access_token): # noqa: D301 """Check connection to REANA server. The ``ping`` command allows to test connection to REANA server. Examples: \n \t $ reana-client ping """ try: from reana_client.api.client import ping as rs_ping from reana_client.utils import get_api_url logging.info("Connecting to {0}".format(get_api_url())) response = rs_ping(access_token) msg_color = "red" if response.get("error") else "green" click.secho( "REANA server: {0}\n" "REANA server version: {1}\n" "REANA client version: {2}\n" "Authenticated as: {3} <{4}>\n" "Status: {5}".format( get_api_url(), response.get("reana_server_version", ""), __version__, response.get("full_name", ""), response.get("email"), response.get("status"), ), fg=msg_color, ) logging.debug("Server response:\n{}".format(response)) except Exception as e: logging.debug(traceback.format_exc()) logging.debug(str(e)) display_message( "Could not connect to the selected REANA cluster " "server at {0}:\n{1}".format(get_api_url(), e), msg_type="error", ) ctx.exit(1)
def ping(ctx): """Health check REANA server.""" try: logging.info('Connecting to {0}'.format( current_rs_api_client.swagger_spec.api_url)) response = rs_ping() click.echo( click.style('Connected to {0} - Server is running.'.format( current_rs_api_client.swagger_spec.api_url), fg='green')) logging.debug('Server response:\n{}'.format(response)) except MissingAPIClientConfiguration as e: click.secho('REANA client is not connected to any REANA cluster.', fg='red') except Exception as e: logging.debug(traceback.format_exc()) logging.debug(str(e)) click.echo(click.style('Could not connect to the selected ' 'REANA cluster server at {0}.'.format( current_rs_api_client.swagger_spec.api_url), fg='red'), err=True)