Discussion:
[Fab-user] Prepend output with hostname when using Groups (fabric.group.Group)
Abhijeet Rastogi
2018-05-15 05:14:10 UTC
Permalink
Hi everyone,

I have a use-case where I can't use the Fabric command directly. I run my
tasks as:-

from fabric import ThreadingGroup as Group
from fabric.exceptions import GroupException

hosts = ['web1', 'web2', 'web3']
g = Group(*hosts)

results = g.run('date')

Now, as I don't use "hide=both" with the "g.run" function call, the stdout
of the command is printed in the terminal directly.

How do I prepend the output with the "fabric.connection.Connection" it's
associated with, in a streaming way. I know, I can collect the output with
the "results" that is returned but I want to do that in a streaming way and
not after all commands are finished executing. (just like it happened with
the older fabric.api.execute 1.0 version API)
--
Cheers,
Abhijeet Rastogi (shadyabhi)
Jeff Forcier
2018-05-15 12:01:31 UTC
Permalink
Hi Abhijeet,

Please check out the upgrading page for all details like this! It is very
thorough (both a blessing and a curse). Specifically, search it for
'output_prefix' which was the name of the old setting controlling that
behavior.

http://docs.fabfile.org/en/latest/upgrading.html

Spoiler: this is one of the larger missing pieces that we'll be working to
figure out in the near term. It may end up being line-by-line prefixes
again, possibly via a logging module; or we might come up with something
else. Suggestions welcome!

Thanks,
Jeff
Post by Abhijeet Rastogi
Hi everyone,
I have a use-case where I can't use the Fabric command directly. I run my
tasks as:-
from fabric import ThreadingGroup as Group
from fabric.exceptions import GroupException
hosts = ['web1', 'web2', 'web3']
g = Group(*hosts)
results = g.run('date')
Now, as I don't use "hide=both" with the "g.run" function call, the stdout
of the command is printed in the terminal directly.
How do I prepend the output with the "fabric.connection.Connection" it's
associated with, in a streaming way. I know, I can collect the output with
the "results" that is returned but I want to do that in a streaming way and
not after all commands are finished executing. (just like it happened with
the older fabric.api.execute 1.0 version API)
--
Cheers,
Abhijeet Rastogi (shadyabhi)
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
--
Jeff Forcier
Unix sysadmin; Python engineer
http://bitprophet.org
Abhijeet Rastogi
2018-05-15 13:38:49 UTC
Permalink
Hi Jeff,

Thanks for the details. So, it is something that's yet to be worked upon (I
see it as Pending). That means, for now, we don't have a way of doing so?
Post by Jeff Forcier
Hi Abhijeet,
Please check out the upgrading page for all details like this! It is very
thorough (both a blessing and a curse). Specifically, search it for
'output_prefix' which was the name of the old setting controlling that
behavior.
http://docs.fabfile.org/en/latest/upgrading.html
Spoiler: this is one of the larger missing pieces that we'll be working to
figure out in the near term. It may end up being line-by-line prefixes
again, possibly via a logging module; or we might come up with something
else. Suggestions welcome!
Thanks,
Jeff
Post by Abhijeet Rastogi
Hi everyone,
I have a use-case where I can't use the Fabric command directly. I run my
tasks as:-
from fabric import ThreadingGroup as Group
from fabric.exceptions import GroupException
hosts = ['web1', 'web2', 'web3']
g = Group(*hosts)
results = g.run('date')
Now, as I don't use "hide=both" with the "g.run" function call, the
stdout of the command is printed in the terminal directly.
How do I prepend the output with the "fabric.connection.Connection" it's
associated with, in a streaming way. I know, I can collect the output with
the "results" that is returned but I want to do that in a streaming way and
not after all commands are finished executing. (just like it happened with
the older fabric.api.execute 1.0 version API)
--
Cheers,
Abhijeet Rastogi (shadyabhi)
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
--
Jeff Forcier
Unix sysadmin; Python engineer
http://bitprophet.org
--
Cheers,
Abhijeet Rastogi (shadyabhi)
Jeff Forcier
2018-05-15 16:52:22 UTC
Permalink
That's what 'Pending' means, yes! It's pending, as in, not yet done. You
already noted the only obvious workaround, which is to display the output
after the fact yourself via the result object. It's very non-ideal which is
why I listed it as "Pending" (wants somebody to work on it) and not
"Removed" (not worth having in core because users can work around it).

PS - your other query to the list can be answered the same way - execute()
is also "Pending". Both are high profile missing features right now and I
expect some basic, if not complete, solutions for them to appear in feature
releases soon.
Post by Abhijeet Rastogi
Hi Jeff,
Thanks for the details. So, it is something that's yet to be worked upon
(I see it as Pending). That means, for now, we don't have a way of doing so?
Post by Jeff Forcier
Hi Abhijeet,
Please check out the upgrading page for all details like this! It is very
thorough (both a blessing and a curse). Specifically, search it for
'output_prefix' which was the name of the old setting controlling that
behavior.
http://docs.fabfile.org/en/latest/upgrading.html
Spoiler: this is one of the larger missing pieces that we'll be working
to figure out in the near term. It may end up being line-by-line prefixes
again, possibly via a logging module; or we might come up with something
else. Suggestions welcome!
Thanks,
Jeff
On Tue, May 15, 2018 at 1:14 AM, Abhijeet Rastogi <
Post by Abhijeet Rastogi
Hi everyone,
I have a use-case where I can't use the Fabric command directly. I run
my tasks as:-
from fabric import ThreadingGroup as Group
from fabric.exceptions import GroupException
hosts = ['web1', 'web2', 'web3']
g = Group(*hosts)
results = g.run('date')
Now, as I don't use "hide=both" with the "g.run" function call, the
stdout of the command is printed in the terminal directly.
How do I prepend the output with the "fabric.connection.Connection" it's
associated with, in a streaming way. I know, I can collect the output with
the "results" that is returned but I want to do that in a streaming way and
not after all commands are finished executing. (just like it happened with
the older fabric.api.execute 1.0 version API)
--
Cheers,
Abhijeet Rastogi (shadyabhi)
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
--
Jeff Forcier
Unix sysadmin; Python engineer
http://bitprophet.org
--
Cheers,
Abhijeet Rastogi (shadyabhi)
--
Jeff Forcier
Unix sysadmin; Python engineer
http://bitprophet.org
Loading...