Initial commit.

This commit is contained in:
2026-01-21 13:12:04 -05:00
commit 1e9e5a5925
190 changed files with 25707 additions and 0 deletions
+167
View File
@@ -0,0 +1,167 @@
# GPLv3 or later.
# (C) J.Y.Amihud 2025
# Program that troubleshoots execution of python scrips.
try:
import importlib.util
except:
NotFoundError("importlib.util")
exit()
try:
import os
except:
NotFoundError("os")
exit()
import __main__
count = 0
broken = 0
checked = []
def run():
global count
global broken
mainfilename = __main__.__file__
check(mainfilename)
if broken:
print()
print(" "+str(broken)+" missing modules found.")
print(" It is "+str(int(round(broken/count*100)))+"% of the program broken.")
print(" Running may introduce issues.")
print()
print(" You can try to run:")
print(" $ python3 -m pip install {module}")
print(" To install missing modules.")
print()
yn = input(clr["tdyl"]+"[ ? ]"+clr["norm"]+" Try to run anyway? ( Y/n ): ")
if "y" not in yn.lower():
exit()
def check(filename):
global count
global broken
global checked
checked.append(filename)
checkalso = []
text = open(filename, "r")
text = text.read()
if __file__ in filename:
return
for line in text.split("\n"):
if "import" in line and __name__ not in line:
if line.strip().startswith("from"):
line = line.strip()[5:]
line = line.replace(" import ", ".").strip()
if line.endswith("*"):
line = line[:-2]
elif line.strip().startswith("import"):
line = line.replace("import", "").strip()
else:
continue
if "," in line:
line = line[:line.find(",")].strip()
count += 1
try:
spec = importlib.util.find_spec(line)
except:
try:
line = line[:line.rfind(".")]
spec = importlib.util.find_spec(line)
except:
print(clr["tdyl"]+"[ ? ]"+clr["norm"], line)
continue
if spec:
#Found(spec)
if os.getcwd() in str(spec.origin):
checkalso.append(spec.origin)
else:
NotFoundError(line, filename)
broken += 1
if checkalso:
for f in checkalso:
if f not in checked:
try:
check(f)
except:
pass
def Found(spec):
print(clr["tdgr"]+"[ v ]"+clr["norm"], spec.name)
def NotFoundError(module, filename=""):
print(clr["tdrd"]+"[ x ]"+clr["norm"], module, clr["tbbl"]+"in "+filename+clr["norm"])
clr = {
"norm":"\033[00m", # Reset to normal
"bold":"\033[01m", # Bold Text
"ital":"\033[03m", # Italic Text
"undr":"\033[04m", # Underlined
"blnk":"\033[05m", # Blinking
# Text
"tdbl":"\033[30m", # Dark Black
"tdrd":"\033[31m", # Dark Red
"tdgr":"\033[32m", # Dark Green
"tdyl":"\033[33m", # Dark Yellow
"tdbu":"\033[34m", # Dark Blue
"tdma":"\033[35m", # Dark Magenta
"tdcy":"\033[36m", # Dark Cyan
"tdwh":"\033[37m", # Dark White
"tbbl":"\033[90m", # Bright Black
"tbrd":"\033[91m", # Bright Red
"tbgr":"\033[92m", # Bright Green
"tbyl":"\033[93m", # Bright Yellow
"tbbu":"\033[94m", # Bright Blue
"tbma":"\033[95m", # Bright Magenta
"tbcy":"\033[96m", # Bright Cyan
"tbwh":"\033[97m", # Bright White
# Background
"bdbl":"\033[40m", # Dark Black
"bdrd":"\033[41m", # Dark Red
"bdgr":"\033[42m", # Dark Green
"bdyl":"\033[43m", # Dark Yellow
"bdbu":"\033[44m", # Dark Blue
"bdma":"\033[45m", # Dark Magenta
"bdcy":"\033[46m", # Dark Cyan
"bdwh":"\033[47m", # Dark White
"bbbl":"\033[100m", # Bright Black
"bbrd":"\033[101m", # Bright Red
"bbgr":"\033[102m", # Bright Green
"bbyl":"\033[103m", # Bright Yellow
"bbbu":"\033[104m", # Bright Blue
"bbma":"\033[105m", # Bright Magenta
"bbcy":"\033[106m", # Bright Cyan
"bbwh":"\033[108m" # Bright White
}