-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventIssuer.py
More file actions
135 lines (115 loc) · 4.81 KB
/
Copy pathEventIssuer.py
File metadata and controls
135 lines (115 loc) · 4.81 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
########################################
########################################
####### Author : Abhinandan Dubey (alivcor)
####### Stony Brook University
from logwriter import *
import sys
class bcolors:
PINK = '\033[95m'
LIME = '\033[0;32m'
YELLOW = '\033[93m'
VIOLET = '\033[0;35m'
BROWN = '\033[0;33m'
INDIGO = "\033[0;34m"
BLUE = "\033[0;34m"
LIGHTPURPLE = '\033[1;35m'
LIGHTRED = '\033[1;31m'
NORMAL = '\033[0;37m'
SHARP = '\033[1;30m'
FAIL = '\033[91m'
END = '\033[0m'
BOLD = '\033[1m'
SLEEP = '\033[90m'
UNDERLINE = '\033[4m'
def disable(self):
self.HEADER = ''
self.OKBLUE = ''
self.OKGREEN = ''
self.WARNING = ''
self.FAIL = ''
self.END = ''
def issueMessage(text, logfilename, ifBold=False):
if ifBold:
toprint = "{.NORMAL}{.BOLD}(Iresium Engine){.END}" + " : " + text
print toprint.format(bcolors, bcolors, bcolors)
else:
toprint = "{.NORMAL}(Iresium Engine){.END}" + " : " + text
print toprint.format(bcolors, bcolors)
with open(logfilename, 'a') as f:
f.write("\n(Iresium Engine) : " + text)
def issueSleep(text, logfilename, ifBold=False):
if ifBold:
toprint = "{.SLEEP}{.BOLD}(Iresium Engine){.END}" + " : " + text
print toprint.format(bcolors, bcolors, bcolors)
else:
toprint = "{.SLEEP}(Iresium Engine){.END}" + " : " + text
print toprint.format(bcolors, bcolors)
with open(logfilename, 'a') as f:
f.write("\n(Iresium Engine) : " + text)
def issueSharpAlert(text, logfilename, highlight=False):
if highlight:
toprint = "{.BOLD}(Iresium Engine)" + " : " + text + "{.END}"
print toprint.format(bcolors, bcolors)
else:
toprint = "{.BOLD}(Iresium Engine){.END}" + " : " + text
print toprint.format(bcolors, bcolors)
with open(logfilename, 'a') as f:
f.write("\n(Iresium Engine) : " + text)
def issueError(text, logfilename, ifBold=False):
if ifBold:
toprint = "{.FAIL}{.BOLD}(Iresium Engine){.END}" + " : " + text
print toprint.format(bcolors, bcolors, bcolors)
else:
toprint = "{.FAIL}(Iresium Engine){.END}" + " : " + text
print toprint.format(bcolors, bcolors)
with open(logfilename, 'a') as f:
f.write("\n(Iresium Engine) : " + text)
def issueWelcome(logfilename):
print "{.BLUE}{.BOLD} IRESIUM ENGINE {.END}".format(bcolors, bcolors, bcolors)
with open(logfilename, 'a') as f:
f.write("IRESIUM Engine")
print "\n\n"
with open(logfilename, 'a') as f:
f.write("\n\n(Iresium Engine) : Welcome to Iresium v0.1")
toprint = "{.BLUE}{.BOLD}(Iresium Engine){.END}" + " : " + "Welcome to Iresium v0.1"
print toprint.format(bcolors, bcolors, bcolors)
def issueSuccess(text, logfilename, ifBold=False, highlight=False):
if highlight:
toprint = "{.LIME}{.BOLD}(Iresium Engine)" + " : " + text + "{.END}"
print toprint.format(bcolors, bcolors, bcolors)
else:
if ifBold:
toprint = "{.LIME}{.BOLD}(Iresium Engine){.END}" + " : " + text
print toprint.format(bcolors, bcolors, bcolors)
else:
toprint = "{.LIME}(Iresium Engine){.END}" + " : " + text
print toprint.format(bcolors, bcolors)
with open(logfilename, 'a') as f:
f.write("\n(Iresium Engine) : " + text)
def genLogFile(logfilename, ts, strts):
toprint = "{.LIME}{.BOLD}(Iresium Engine){.END}" + " : " + "Logging all events to " + str(ts)
print toprint.format(bcolors, bcolors, bcolors)
with open(logfilename, 'a') as f:
f.write("\n(Iresium Engine) : " + "Log File Created at : " + str(strts))
f.write("\n(Iresium Engine) : " + "Logging all events to " + str(ts))
def issueWarning(text, logfilename, ifBold=False):
if ifBold:
toprint = "{.BROWN}{.BOLD}(Iresium Engine){.END}" + " : " + text
print toprint.format(bcolors, bcolors, bcolors)
else:
toprint = "{.BROWN}(Iresium Engine){.END}" + " : " + text
print toprint.format(bcolors, bcolors)
with open(logfilename, 'a') as f:
f.write("\n(Iresium Engine) : " + text)
# issueWelcome()
# issueMessage("I'm glad you're here !")
# issueSleep("I'm turning to sleep mode.")
# issueSharpAlert("I'm back up. You need to look into this.")
# issueWarning("There's some problem with my core")
# issueError("I have to shutdown. Please mail the administrator the log file I've generated.")
#
def issueExit(logfilename, ts):
toprint = "{.LIGHTPURPLE}{.BOLD}(Iresium Engine){.END}" + " : Shutting down the engine. Logs have been saved. Have a good day !"
print toprint.format(bcolors, bcolors, bcolors)
genpdfcmd = "python logwriter.py " + logfilename + " -S \"LOG FILE\" -A \"Iresium Engine\" -o logs/Iresium_Log_" + str(ts) + ".pdf"
os.system(genpdfcmd)