Fabric color-colored output class (color)

Source: Internet
Author: User

1. Call Method:
From fabric import Colors
2. Method:
Print Colors.blue (String) #蓝
Print colors.red (String) #红
Print Colors.cyan (String) #浅蓝
Print Colors.green (String) #绿
Print Colors.magenta (String) #紫
Print Colors.white (String) #白
Print Colors.yellow (String) #黄
3. Practice:

#!/bin/env python2.7
#-*-coding:utf-8-*-
From fabric import Colors

def color (color_type= ' blue ', string= ' Nimei '):
If color_type== ' Blue ':
Print Colors.blue (String)
return Colors.blue (String)
Elif color_type== ' Red ':
Print colors.red (String)
return colors.red (String)
Elif color_type== ' cyan ':
Print Colors.cyan (String)
return Colors.cyan (String)
Elif color_type== ' green ':
Print Colors.green (String)
return Colors.green (String)
Elif color_type== ' Magenta ':
Print Colors.magenta (String)
return Colors.magenta (String)
Elif color_type== ' white ':
Print Colors.white (String)
return Colors.white (String)
Elif color_type== ' Yellow ':
Print Colors.yellow (String)
return Colors.yellow (String)
Else
Print ""
You need to enter two parameters, one is color (color_type):(blue|red|cyan|green|magenta|white|yellow).
The other is any string
‘‘‘
Return None

@hosts (' 192.168.1.219 ')
def test (String):
With settings (warn_only=true):
status= Run (String)
If status.succeeded:
Color (' green ', ' OK ')
Else
Color (' Red ', ' error ')


#执行
#fab-F colors.py Color
#fab-H 192.168.1.219-f colors.py test: ' abc '
#fab-H 192.168.1.219-f colors.py test: ' TOUCH/TMP/DIR/1 '


This article from "My Sky" blog, declined reprint!

Fabric color-colored output class (color)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.