-
Notifications
You must be signed in to change notification settings - Fork 0
/
Trace.py
66 lines (47 loc) · 2.02 KB
/
Trace.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
import datetime
from tkinter import *
import os.path
import random
class Trace:
def __init__(self):
global const_Filename
self.filename = datetime.date.today().__str__()
const_Filename = self.filename
while os.path.exists(const_Filename):
const_Filename = self.filename + str(chr(random.randint(67, 122))) + ".txt"
file = open(const_Filename, "a")
file.write("*** STACK TRACE STARTED ***\n")
file.close()
def Trace(self, event):
self.Event = event
if self.Event == "":
file = open(const_Filename, "a")
file.write(f"[{datetime.datetime.now()}]:::[Raised ValueError, Tracer Must Have Valid Event]\n")
file.close()
else:
file = open(const_Filename, "a")
file.write(f"[{datetime.datetime.now()}]:::[{self.Event}]\n")
file.close()
def EndTrace(self):
self.EndEvent = "Stack Trace End\n"
file = open(const_Filename, "a")
file.write(self.EndEvent)
file.write(f"Stack trace ended at: {datetime.datetime.now()}\n")
file.write("*** STACK TRACE ENDED ***\n")
class _EndTrace:
def __init__(self):
print(f"New Contrauctor: {self} created")
def _EndTrace(self, master: object, row: object, column: object, _width: object, _height: object, _bg: object, _fg: object) -> object:
self.Master = master
self.Y = row
self.X = column
self.Width = _width
self.Height = _height
EndTraceButton = Button(self.Master, text= "End", width= self.Width, height= self.Height, bg= _bg, fg=_fg, command=_EndTrace.__EndTrace)
EndTraceButton.grid(row=self.Y, column=self.X)
@staticmethod
def __EndTrace():
file = open(const_Filename, "a")
file.write(f"Stack Trace Ended at: {datetime.datetime.now()}\n")
file.write("*** STACK TRACE ENDED ***\n")
exit()