Fabric: hide('running') on the task level is broken

Created on 25 Aug 2011  ·  9Comments  ·  Source: fabric/fabric

1) it does not hide stuff like 'executing task...'
2) it removes newlines from the last output, thus joining the next line of output

fabfile is:
@task
def show_hostname():
with settings(hide('running')):
run('hostname')
run('date')

% /opt/python-2.7/bin/fab -f output.py -H x1,x2 show_hostname
[x1] Executing task 'show_hostname'
[x1] out: x1mydomain.de
[x1] out: [x1] out: Thu Aug 25 10:34:10 CEST 2011
[x1] out: [x2] Executing task 'show_hostname'
[x2] out: x2.mydomain.de
[x2] out: [x2] out: Thu Aug 25 10:34:11 CEST 2011
[x2] out:
Done.

and while we are at it:

3) run('hostname') for example always outputs an empty line like so:

[h1] Executing task 'show_hostname'
[h1] out: h1.mydomain.de
[h1] out:

is 3) by purpose and are 1,2 problems coming from that empty line?

Thanks,
Sven

Bug UI

Most helpful comment

  • how to also hide the "Done." printed after completion?
  • how to also hide the "Disconnecting from my.server.com... done."?

It would be useful if I could just disable ALL (really literally all) output except what I explicitly print out, except when there's a problem.

All 9 comments

if you look at fabric.main:main, you'll see the 'executing' happens _outside_ the task, which is why it's not hidden, by the hide. As a work around (global!) you can set fabric.state.output['running'] = False, or pass in --hide=running.

Gregg is right re: executing -- it needs to be a global setting due to when the "Executing" lines are printed -- though I acknowledge that it's not terrifically intuitive and wish there was a better way around it. (I can think of one way to do it for new-style tasks, but not sure it's worth increasing the differences in behavior between the two types, at the moment...)

Newlines at the end of stdout blocks are on purpose, IIRC, though I can't recall if we are explicitly inserting them or if it's actually from the remote end (and is just triggering a new line prefix.) But I don't think it's a bug _per se_.

The "missing" newlines may be related -- I'd have to double check. May be a situation where it was going to look ugly one way or another and we had to shift the ugliness to the less common case.

Is there any update on this bug/UI inconsistency? I'm trying to tail a file via fabric, and it'd be great to mask those "[hostname]" output.

I tried fabric.state.output['running'] = False, nothing change.

@charlax You can use fab --hide=running and that will flip that output level off from the very start of the run, so it should hide all the 'running task x' stuff that is not hideable from inside tasks themselves. Not sure why I didn't mention this in the earlier comment.

You should also be able to make that fabric.state.output change you mentioned, at module (top) level in your fabfile -- where exactly did you put it when you tried? If it's inside a task it still won't work.

Oh right, actually what I'm trying to do is hide the [host.com] out: part, sorry for the misunderstanding.

Meaning _just_ that part of the line? There is a private config setting for that, but I don't see that changing before fab 2.0 comes out, so I'll let you in on the secret: it's env.output_prefix, set it to False and it will just print literal stdout/stderr with no line prefixes.

Thanks!

Seems like the @hosts() decorator should make it possible to hide the 'host' part of the running output without forcing disabling of

fabric.state.output['running']

globally . This would allow overriding the env.hosts for a single method which is what it is meant to do. It seems that it should behave as the env.hosts in that setting it to an empty iterator (or None) should trigger the local_only execution which would not print the host. Currently, an empty iterator in @hosts is ignored and it falls back to using env.hosts. If it will get pulled I will write a patch.

  • how to also hide the "Done." printed after completion?
  • how to also hide the "Disconnecting from my.server.com... done."?

It would be useful if I could just disable ALL (really literally all) output except what I explicitly print out, except when there's a problem.

Was this page helpful?
0 / 5 - 0 ratings