-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprinter.py
69 lines (57 loc) · 1.44 KB
/
printer.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
"""
printer.py
Shows message on the user's terminal.
"""
import sys
import datetime
# Color definitions
HEADER = '\033[95m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
ENDCOLOR = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
def timestamp():
"""
Return formated timestamp.
"""
return datetime.datetime.now().strftime("%H:%M:%S")
def info(text):
"""
Print info message.
"""
msg = "{c}{ts} {t} {ec}".format(c=BLUE,
ts=timestamp(),
t=text,
ec=ENDCOLOR)
print(msg)
def warning(text):
"""
Print info message.
"""
msg = "{c}{ts} {t} {ec}".format(c=YELLOW,
ts=timestamp(),
t=text,
ec=ENDCOLOR)
print(msg)
def error(text):
"""
Print info message.
"""
msg = "{c}{ts} {t} {ec}".format(c=RED,
ts=timestamp(),
t=text,
ec=ENDCOLOR)
print(msg)
sys.exit(1)
def substep_info(text):
"""
Print info message.
"""
msg = "{c}.- {ts} {t} {ec}".format(c=BLUE,
ts=timestamp(),
t=text,
ec=ENDCOLOR)
print(msg)