def test_show(self):
     """Establish that the show method will properly route to an
     alternate file.
     """
     sio = StringIO()
     ex = TowerCLIError('Fe fi fo fum; I smell the blood of an Englishman.')
     ex.show(file=sio)
     sio.seek(0)
     self.assertIn('Fe fi fo fum;', sio.read())
Beispiel #2
0
def version(**kwargs):
    """Display version information."""

    # Print out the current version of Tower CLI.
    click.echo('Tower CLI %s' % __version__)

    # Attempt to connect to the Ansible Tower server.
    # If we succeed, print a version; if not, generate a failure.
    try:
        r = client.get('/config/')
        click.echo('Ansible Tower %s' % r.json()['version'])
    except RequestException as ex:
        raise TowerCLIError('Could not connect to Ansible Tower.\n%s' %
                            six.text_type(ex))