Discussion:
[Fab-user] Command status output OK in green color and FAILED in red color
Kaushal Shriyan
2015-06-01 11:45:59 UTC
Permalink
Hi,

Is there a native feature available in fabric tool similar to the example
given in
http://stackoverflow.com/questions/5506176/bash-echo-something-to-right-end-of-window-right-aligned
?

For example if the command is successful then OK in green color and FAILED
in red color
Any examples?

I would appreciate your help.

Regards,

Kaushal
Carlos García
2015-06-01 13:22:11 UTC
Permalink
Hi,

you can use colors, as explained here:
http://docs.fabfile.org/en/1.10/api/core/colors.html
<http://docs.fabfile.org/en/1.6/api/core/colors.html>. You need to use the
value returned when executing run or sudo.

from fabric.colors import red, green
ret_code = sudo("ls -l")

if ret_code.succeeded :
print(green("Success"))
else:
print(red("Error"))

Also, you maby find useful these functions:
http://docs.fabfile.org/en/1.10/api/core/utils.html

Regards
Post by Kaushal Shriyan
Hi,
Is there a native feature available in fabric tool similar to the example
given in
http://stackoverflow.com/questions/5506176/bash-echo-something-to-right-end-of-window-right-aligned
?
For example if the command is successful then OK in green color and FAILED
in red color
Any examples?
I would appreciate your help.
Regards,
Kaushal
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
Kaushal Shriyan
2015-06-01 13:34:39 UTC
Permalink
On Mon, Jun 1, 2015 at 6:52 PM, Carlos García <
Post by Carlos García
Hi,
http://docs.fabfile.org/en/1.10/api/core/colors.html
<http://docs.fabfile.org/en/1.6/api/core/colors.html>. You need to use
the value returned when executing run or sudo.
from fabric.colors import red, green
ret_code = sudo("ls -l")
print(green("Success"))
print(red("Error"))
http://docs.fabfile.org/en/1.10/api/core/utils.html
Regards
Thanks Carlos for the answer.

Regards,

Kaushal
Post by Carlos García
Post by Kaushal Shriyan
Hi,
Is there a native feature available in fabric tool similar to the example
given in
http://stackoverflow.com/questions/5506176/bash-echo-something-to-right-end-of-window-right-aligned
?
For example if the command is successful then OK in green color and
FAILED in red color
Any examples?
I would appreciate your help.
Regards,
Kaushal
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
Loading...