-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
95 lines (75 loc) · 2.35 KB
/
app.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import sys
import os
import subprocess
import tkinter as tk
from tkinter import ttk, Text, Scrollbar
from tkinter.constants import BOTH, BOTTOM, TOP, RIGHT, X, Y
root = tk.Tk()
root.title("Microsoft Error Lookup Wrapper")
root.geometry("1000x500")
root.resizable(True, True)
frame = ttk.Frame(root)
frame.pack(padx=10, pady=10, fill=BOTH, expand=True)
input = "input\Err_6.4.5.exe"
message = "Usage:\n\
1. Search decorated hex (0x54f)\n\
2. Search implicit hex (54f)\n\
3. Search ambiguous (1359)\n\
4. Search exact string (=ERROR_INTERNAL_ERROR)\n\
5. Search substring (:INTERNAL_ERROR)\n\
6. Use show all to output all known error codes\n\
7. Use clear all to clear all input and output fields\n\n\
There are currently 25259 return codes registered from 173 sources."
def resource_path(relative_path):
try:
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
def search(query):
if query == "":
return
text_box.delete("1.0", "end")
with subprocess.Popen(
[resource_path(input), query],
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
bufsize=1,
universal_newlines=True,
) as p:
for line in p.stdout:
text_box.insert(tk.END, line)
def clear():
text_box.delete("1.0", "end")
query_entry.delete(0, "end")
text_box.insert("end", message)
query_var = tk.StringVar()
query_entry = tk.Entry(frame, textvariable=query_var, font="sans 14 bold")
query_entry.pack(side=TOP, fill=X, pady=5)
query_entry.focus()
search_button = tk.Button(
frame, text="search", font="sans 14 bold", command=lambda: search(query_var.get())
)
search_button.pack(fill=X)
showall_button = tk.Button(
frame, text="show all", font="sans 14 bold", command=lambda: search("/:outputtoCSV")
)
showall_button.pack(fill=X)
clear_button = tk.Button(frame, text="clear all", font="sans 14 bold", command=clear)
clear_button.pack(fill=X)
scrollbar = Scrollbar(frame)
scrollbar.pack(side=RIGHT, fill=Y)
text_box = Text(
frame,
height=13,
width=40,
wrap="word",
yscrollcommand=scrollbar.set,
relief="sunken",
)
text_box.pack(side=BOTTOM, pady=10, fill=BOTH, expand=True)
text_box.insert("end", message)
scrollbar.config(command=text_box.yview)
root.mainloop()