Make test/runner less verbose when spawning instances

As discussed on IRC
This commit is contained in:
Dag Wieers 2017-01-26 22:07:10 +01:00 committed by Matt Clay
parent f42fa8879b
commit 3a0a74dc18
3 changed files with 14 additions and 10 deletions

View file

@ -104,8 +104,7 @@ class AnsibleCoreCI(object):
self.connection = self.get(always_raise_on=[404]) self.connection = self.get(always_raise_on=[404])
display.info('Loaded existing %s/%s instance %s.' % (self.platform, self.version, self.instance_id), display.info('Loaded existing %s/%s from: %s' % (self.platform, self.version, self._uri), verbosity=1)
verbosity=1)
except HttpError as ex: except HttpError as ex:
if ex.status != 404: if ex.status != 404:
raise raise
@ -238,7 +237,8 @@ class AnsibleCoreCI(object):
status = 'running' if self.connection.running else 'starting' status = 'running' if self.connection.running else 'starting'
display.info('Retrieved %s %s/%s instance %s.' % (status, self.platform, self.version, self.instance_id), display.info('Status update: %s/%s on instance %s is %s.' %
(self.platform, self.version, self.instance_id, status),
verbosity=1) verbosity=1)
return self.connection return self.connection
@ -307,8 +307,7 @@ class AnsibleCoreCI(object):
self.started = True self.started = True
self._save() self._save()
display.info('Started %s/%s instance %s.' % (self.platform, self.version, self.instance_id), display.info('Started %s/%s from: %s' % (self.platform, self.version, self._uri), verbosity=1)
verbosity=1)
def _clear(self): def _clear(self):
"""Clear instance information.""" """Clear instance information."""

View file

@ -76,7 +76,7 @@ class HttpClient(object):
cmd += [url] cmd += [url]
stdout, _ = run_command(self.args, cmd, capture=True, always=self.always) stdout, _ = run_command(self.args, cmd, capture=True, always=self.always, cmd_verbosity=2)
if self.args.explain and not self.always: if self.args.explain and not self.always:
return HttpResponse(200, '') return HttpResponse(200, '')

View file

@ -78,7 +78,8 @@ def find_executable(executable, cwd=None, path=None, required=True):
return match return match
def run_command(args, cmd, capture=False, env=None, data=None, cwd=None, always=False, stdin=None, stdout=None): def run_command(args, cmd, capture=False, env=None, data=None, cwd=None, always=False, stdin=None, stdout=None,
cmd_verbosity=1):
""" """
:type args: CommonConfig :type args: CommonConfig
:type cmd: collections.Iterable[str] :type cmd: collections.Iterable[str]
@ -89,13 +90,16 @@ def run_command(args, cmd, capture=False, env=None, data=None, cwd=None, always=
:type always: bool :type always: bool
:type stdin: file | None :type stdin: file | None
:type stdout: file | None :type stdout: file | None
:type cmd_verbosity: int
:rtype: str | None, str | None :rtype: str | None, str | None
""" """
explain = args.explain and not always explain = args.explain and not always
return raw_command(cmd, capture=capture, env=env, data=data, cwd=cwd, explain=explain, stdin=stdin, stdout=stdout) return raw_command(cmd, capture=capture, env=env, data=data, cwd=cwd, explain=explain, stdin=stdin, stdout=stdout,
cmd_verbosity=cmd_verbosity)
def raw_command(cmd, capture=False, env=None, data=None, cwd=None, explain=False, stdin=None, stdout=None): def raw_command(cmd, capture=False, env=None, data=None, cwd=None, explain=False, stdin=None, stdout=None,
cmd_verbosity=1):
""" """
:type cmd: collections.Iterable[str] :type cmd: collections.Iterable[str]
:type capture: bool :type capture: bool
@ -105,6 +109,7 @@ def raw_command(cmd, capture=False, env=None, data=None, cwd=None, explain=False
:type explain: bool :type explain: bool
:type stdin: file | None :type stdin: file | None
:type stdout: file | None :type stdout: file | None
:type cmd_verbosity: int
:rtype: str | None, str | None :rtype: str | None, str | None
""" """
if not cwd: if not cwd:
@ -117,7 +122,7 @@ def raw_command(cmd, capture=False, env=None, data=None, cwd=None, explain=False
escaped_cmd = ' '.join(pipes.quote(c) for c in cmd) escaped_cmd = ' '.join(pipes.quote(c) for c in cmd)
display.info('Run command: %s' % escaped_cmd, verbosity=1) display.info('Run command: %s' % escaped_cmd, verbosity=cmd_verbosity)
display.info('Working directory: %s' % cwd, verbosity=2) display.info('Working directory: %s' % cwd, verbosity=2)
program = find_executable(cmd[0], cwd=cwd, path=env['PATH'], required='warning') program = find_executable(cmd[0], cwd=cwd, path=env['PATH'], required='warning')