1.调用方法:
from fabric import colors
2.方法:
    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.练习:

#!/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 '''
          需要输入两个参数,一个是颜色(color_type):(blue|red|cyan|green|magenta|white|yellow).
          另一个是任意字符串(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'