Revision 1bc6d467

b/snf-deploy/fabfile.py
22 22
    print(" * Using %s and %s for packages and templates accordingly..." % (packages, templates))
23 23

  
24 24
    autoconf = ast.literal_eval(autoconf)
25
    disable_colors = ast.literal_eval(disable_colors)
25 26
    conf = Conf.configure(confdir=confdir, cluster_name=cluster_name, autoconf=autoconf)
26 27
    env.env = Env(conf)
27 28

  
......
30 31
    env.user = env.env.user
31 32
    env.shell = "/bin/bash -c"
32 33

  
34
    if disable_colors:
35
        disable_color()
36

  
33 37
    if env.env.cms.hostname in [env.env.accounts.hostname, env.env.cyclades.hostname, env.env.pithos.hostname]:
34 38
      env.cms_pass = True
35 39
    else:
b/snf-deploy/snfdeploy/__init__.py
254 254
    fabcmd = "fab "
255 255

  
256 256
  fabcmd += " --fabfile {4}/fabfile.py \
257
    setup_env:confdir={0},packages={1},templates={2},cluster_name={3},autoconf={5} \
258
    ".format(args.confdir, env.packages, env.templates, args.cluster_name, env.lib, args.autoconf)
257
setup_env:confdir={0},packages={1},templates={2},cluster_name={3},\
258
autoconf={5}, disable_colors={6} \
259
".format(args.confdir, env.packages, env.templates, args.cluster_name,
260
         env.lib, args.autoconf, args.disable_colors)
259 261

  
260 262
  if nodes:
261 263
    hosts = [env.nodes_info[n].hostname for n in nodes]
......
400 402
  parser.add_argument("actions", type=str, nargs="*",
401 403
                      help="Run one or more of the supported subcommands")
402 404

  
405
  # disable colors in terminal
406
  parser.add_argument("--disable-colors", dest="disable_colors", default=False,
407
                      action="store_true", help="Disable colors in terminal")
408

  
403 409
  return parser.parse_args()
404 410

  
411

  
405 412
def get_actions(*args):
406 413
    actions = {
407 414
      # prepare actions
b/snf-deploy/snfdeploy/lib.py
16 16
from snfdeploy import massedit
17 17

  
18 18

  
19
HEADER = '\033[95m'
20
OKBLUE = '\033[94m'
21
OKGREEN = '\033[92m'
22
WARNING = '\033[93m'
23
FAIL = '\033[91m'
24
ENDC = '\033[0m'
25

  
26

  
27
def disable_color():
28
    HEADER = ''
29
    OKBLUE = ''
30
    OKGREEN = ''
31
    WARNING = ''
32
    FAIL = ''
33
    ENDC = ''
34

  
35

  
36
if not sys.stdout.isatty():
37
    disable_color()
19 38

  
20 39
class Host(object):
21 40
    def __init__(self, hostname, ip, mac, domain):
......
164 183
        self.nodes.set("info", "public_iface", get_default_route()[1])
165 184

  
166 185

  
167
class bcolors:
168
    HEADER = '\033[95m'
169
    OKBLUE = '\033[94m'
170
    OKGREEN = '\033[92m'
171
    WARNING = '\033[93m'
172
    FAIL = '\033[91m'
173
    ENDC = '\033[0m'
174

  
175
    def disable(self):
176
        self.HEADER = ''
177
        self.OKBLUE = ''
178
        self.OKGREEN = ''
179
        self.WARNING = ''
180
        self.FAIL = ''
181
        self.ENDC = ''
182

  
183

  
184 186
def debug(host, msg):
185 187

  
186
    print bcolors.HEADER + host + \
187
          bcolors.OKBLUE + ": " + msg + bcolors.ENDC
188
    print HEADER + host + \
189
          OKBLUE + ": " + msg + ENDC
188 190

  
189 191

  
190 192
def check_pidfile(pidfile):

Also available in: Unified diff