forked from h2oai/h2o-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
h2o_print.py
75 lines (62 loc) · 1.61 KB
/
h2o_print.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import getpass
# some fun to match michal's use of green in his messaging in ec2_cmd.py
# generalize like http://stackoverflow.com/questions/287871/print-in-terminal-with-colors-using-python
class bcolors:
PURPLE = ''
BLUE = ''
GREEN = ''
YELLOW = ''
RED = ''
ENDC = ''
def enable(self):
self.PURPLE = '\033[95m'
self.BLUE = '\033[94m'
self.GREEN = '\033[92m'
self.YELLOW = '\033[93m'
self.RED = '\033[91m'
self.ENDC = '\033[0m'
def disable(self):
self.PURPLE = ''
self.BLUE = ''
self.GREEN = ''
self.YELLOW = ''
self.RED = ''
self.ENDC = ''
b = bcolors()
b.enable()
def disable_colors():
b.disable()
def enable_colors():
b.enable()
# make these compatible with multiple args like print?
def green_print(*args):
# the , at the end means no eol
if getpass.getuser()=='jenkins':
b.disable()
for msg in args:
print b.GREEN + str(msg) + b.ENDC,
print
def blue_print(*args):
if getpass.getuser()=='jenkins':
b.disable()
for msg in args:
print b.BLUE + str(msg) + b.ENDC,
print
def yellow_print(*args):
if getpass.getuser()=='jenkins':
b.disable()
for msg in args:
print b.YELLOW + str(msg) + b.ENDC,
print
def red_print(*args):
if getpass.getuser()=='jenkins':
b.disable()
for msg in args:
print b.RED + str(msg) + b.ENDC,
print
def purple_print(*args):
if getpass.getuser()=='jenkins':
b.disable()
for msg in args:
print b.PURPLE + str(msg) + b.ENDC,
print