Revision 1bc6d467 snf-deploy/snfdeploy/lib.py

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