mirror of
https://github.com/outbackdingo/OpCore-Simplify.git
synced 2026-01-27 10:19:49 +00:00
Add detailed error info for easier debugging
This commit is contained in:
@@ -11,6 +11,7 @@ import updater
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import traceback
|
||||
|
||||
class OCPE:
|
||||
def __init__(self):
|
||||
@@ -201,12 +202,16 @@ class OCPE:
|
||||
self.results(hardware_report, smbios_model)
|
||||
|
||||
if __name__ == '__main__':
|
||||
update_flag = updater.Updater().run_update()
|
||||
if update_flag:
|
||||
os.execv(sys.executable, ['python3'] + sys.argv)
|
||||
|
||||
o = OCPE()
|
||||
try:
|
||||
update_flag = updater.Updater().run_update()
|
||||
if update_flag:
|
||||
os.execv(sys.executable, ['python3'] + sys.argv)
|
||||
else:
|
||||
while True:
|
||||
try:
|
||||
o.main()
|
||||
except Exception as e:
|
||||
o.u.exit_program(o.u.message("\nAn error occurred: {}\n".format(e)))
|
||||
except Exception as e:
|
||||
o.u.head("An Error Occurred")
|
||||
print("")
|
||||
print(traceback.format_exc())
|
||||
o.u.request_input()
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import plistlib
|
||||
import shutil
|
||||
@@ -217,28 +218,9 @@ class Utils:
|
||||
cols = max(len(line) for line in lines) if lines else 0
|
||||
print('\033[8;{};{}t'.format(max(rows+6, 30), max(cols+2, 100)))
|
||||
|
||||
@staticmethod
|
||||
def message(text, msg_type="attention"):
|
||||
# ANSI escape codes for different colors and bold font
|
||||
RED_BOLD = "\033[1;31m"
|
||||
YELLOW_BOLD = "\033[1;33m"
|
||||
CYAN_BOLD = "\033[1;36m"
|
||||
RESET = "\033[0m"
|
||||
|
||||
if msg_type == "attention":
|
||||
color_code = RED_BOLD
|
||||
elif msg_type == "warning":
|
||||
color_code = YELLOW_BOLD
|
||||
elif msg_type == "reminder":
|
||||
color_code = CYAN_BOLD
|
||||
else:
|
||||
color_code = RESET
|
||||
|
||||
return "{}{}{}".format(color_code, text, RESET)
|
||||
|
||||
def exit_program(self, custom_content=""):
|
||||
def exit_program(self):
|
||||
self.head()
|
||||
print(custom_content)
|
||||
print("")
|
||||
print("For more information, to report errors, or to contribute to the product:")
|
||||
print("* Facebook: https://www.facebook.com/macforce2601")
|
||||
print("* Telegram: https://t.me/lzhoang2601")
|
||||
@@ -246,4 +228,5 @@ class Utils:
|
||||
print("")
|
||||
|
||||
print("Thank you for using our program!\n")
|
||||
exit(0)
|
||||
self.request_input("Press Enter to exit.")
|
||||
sys.exit(0)
|
||||
Reference in New Issue
Block a user