commit 056f15d6470bb12c9ce50158b28a59feef0e496c Author: Fierelier Date: Tue Mar 16 20:28:29 2021 +0100 first commit diff --git a/compile.bat b/compile.bat new file mode 100644 index 0000000..d4f1635 --- /dev/null +++ b/compile.bat @@ -0,0 +1,76 @@ +@echo off +setlocal +set distro=fspecs +cd /d %~dp0 + +:arch +echo 1) 32-bit (recommended) +echo 2) 64-bit +set /p arch= +echo. +if not "%arch%" == "1" if not "%arch%" == "2" goto arch + +if exist "%cd%\dist" ( + echo deleting old dist... + rmdir /s /q "%cd%\dist" + if not "%errorlevel%" == "0" echo something went wrong while deleting old dist & goto error +) + +if not exist "%cd%\python34" ( + echo. + echo downloading python 3.4.4... + if "%arch%" == "1" curl https://www.python.org/ftp/python/3.4.4/python-3.4.4.msi -o python-3.4.4.msi + if "%arch%" == "2" curl https://www.python.org/ftp/python/3.4.4/python-3.4.4.amd64.msi -o python-3.4.4.msi + if not "%errorlevel%" == "0" echo something went wrong while downloading python & goto error + + echo. + echo extracting python 3.4.4... + start /wait msiexec /a "%cd%\python-3.4.4.msi" /qb targetdir="%cd%\python34" + if not "%errorlevel%" == "0" echo something went wrong while extracting python & goto error + del "%cd%\python-3.4.4.msi" +) + +REM set path +set path=%cd%\python34;%path% + +REM check version +python.exe --version | find /i "3.4.4" >nul +if not "%errorlevel%" == "0" echo something went wrong while setting the path (wrong version) & goto error + +echo. +echo installing prerequisites... +python.exe -c "import ensurepip;ensurepip.bootstrap()" +if not "%errorlevel%" == "0" echo something went wrong while installing a prerequisite & goto error +python.exe -m pip install "PyInstaller==3.4" +if not "%errorlevel%" == "0" echo something went wrong while installing a prerequisite & goto error +python.exe -m pip install "colorama==0.3.5" +if not "%errorlevel%" == "0" echo something went wrong while installing a prerequisite & goto error + +echo. +echo compiling script... +python.exe -m PyInstaller "%cd%\%distro%.py" --onefile +if not "%errorlevel%" == "0" echo something went wrong while compiling a script & goto error + +echo. +echo copying config files... +copy "%cd%\%distro%.ini" "%cd%\dist" +copy "%cd%\%distro%.ascii-*" "%cd%\dist" + +echo. +echo cleaning up... +rmdir /s /q "%cd%\build" +rmdir /s /q "%cd%\__pycache__" +del %distro%.spec + +REM done +echo. +echo done. +echo you can find the EXEs in dist\ +pause +goto exit + +:error +pause +goto exit + +:exit \ No newline at end of file diff --git a/fspecs.ascii-chroma.txt b/fspecs.ascii-chroma.txt new file mode 100644 index 0000000..913d4ae --- /dev/null +++ b/fspecs.ascii-chroma.txt @@ -0,0 +1,9 @@ + AAAAAAAAAAAAAAAAAAAAAAAA BBB + BBBBBBBBBBAABBBBAACCCCAA CCC + BBBBBBBBBBAABBBBAACCCCAA + BBBBBBBBBBAABBBBAACCCCAA GGG + AAAAAAAAAAAAAAAAAAAAAAAA DDD + GGGGGGGGGGAAGGGGAADDDDAA BBB + GGGGGGGGGGAAGGGGAADDDDAA CCC + GGGGGGGGGGAAGGGGAADDDDAA + AAAAAAAAAAAAAAAAAAAAAAAA GGG \ No newline at end of file diff --git a/fspecs.ascii-luma.txt b/fspecs.ascii-luma.txt new file mode 100644 index 0000000..a3c7ed9 --- /dev/null +++ b/fspecs.ascii-luma.txt @@ -0,0 +1,9 @@ + ************************ + ##########**####**####** + ##########**####**####** + ##########**####**####** + ************************ + ##########**####**####** + ##########**####**####** + ##########**####**####** + ************************ \ No newline at end of file diff --git a/fspecs.ini b/fspecs.ini new file mode 100644 index 0000000..ffdf057 --- /dev/null +++ b/fspecs.ini @@ -0,0 +1,2 @@ +[default] +msg = (;ΦwΦ)_┌─ ))Windows 10'(( \ No newline at end of file diff --git a/fspecs.py b/fspecs.py new file mode 100644 index 0000000..1f0a553 --- /dev/null +++ b/fspecs.py @@ -0,0 +1,225 @@ +# init +print("LOADING...",end="\r") +import sys +oldexcepthook = sys.excepthook +def newexcepthook(type,value,traceback): + oldexcepthook(type,value,traceback) + input("Press ENTER to quit.") +sys.excepthook = newexcepthook + +import os +import subprocess +import colorama +import shutil +import configparser + +p = os.path.join +s = False +if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): + s = os.path.realpath(sys.executable) +else: + s = os.path.realpath(__file__) +sp = os.path.dirname(s) + +# script +colorama.init() +x,y = shutil.get_terminal_size((80, 20)) +x = x - 1 + +pathConfig = p(sp,os.path.splitext(os.path.basename(s))[0] + ".ini") +pathAsciiLuma = p(sp,os.path.splitext(os.path.basename(s))[0] + ".ascii-luma.txt") +pathAsciiChroma = p(sp,os.path.splitext(os.path.basename(s))[0] + ".ascii-chroma.txt") + +config = configparser.ConfigParser() +config["default"] = { + "msg": "???" +} +config.read(pathConfig,encoding="utf-8") + +asciiLuma = open(pathAsciiLuma,"r",encoding="utf-8").read() +asciiChroma = open(pathAsciiChroma,"r",encoding="utf-8").read() + +colors = { + "a":colorama.Fore.BLACK, + "b":colorama.Fore.RED, + "c":colorama.Fore.GREEN, + "d":colorama.Fore.YELLOW, + "e":colorama.Fore.BLUE, + "f":colorama.Fore.MAGENTA, + "g":colorama.Fore.CYAN, + "h":colorama.Fore.WHITE, + "i":colorama.Fore.RESET +} + +def getInfo(part,defn,index = 0): + try: + part = part.split(" ") + out = subprocess.check_output(["wmic"] +part+ ["get",defn],stderr=subprocess.DEVNULL).decode("utf-8").split("\n")[1 + index] + except: + return False + + out = out.replace("\r","") + + try: + while out[0] == " " or out[0] == " ": + out = out[1:] + while out[-1] == " " or out[-1] == " ": + out = out[:-1] + except: + return False + + return out + +def qi(part,defn,index = 0): + info = "" + try: + info = getInfo(part,defn,index) + except: + info = "???" + if info == False: info = "???" + return info + +def getSpecs(): + info = [] + + #OPERATING SYSTEM + info.append("OPS") + try: + info.append(subprocess.check_output(["ver"],shell=True).decode("utf-8").replace("\n","").replace("\r","")) + except: + info.append("???") + + #HOST + info.append("HST") + try: + info.append(os.environ["USERNAME"] +"@"+ os.environ["USERDOMAIN"]) + except: + info.append("???") + info.append("");info.append("") + + #BOARD + info.append("BRD") + info.append(qi("baseboard","manufacturer") + " " + qi("baseboard","product")) + + #CPU + info.append("CPU") + info.append(qi("cpu","name")) + + #MEMORY + info.append("MEM") + memCap = 0 + index = 0 + while True: + minfo = qi("memorychip","capacity",index) + if minfo == "???": break + memCap = memCap + (int(minfo) / 1024 / 1024) + index = index + 1 + + if memCap == 0: memCap = "???" + memInfo = str(memCap) + " MB @ " +qi("memorychip","speed")+ "MHz" + + info.append(memInfo) + + #GPU + info.append("GPU") + info.append(qi("path win32_VideoController","name")) + return info + +information = getSpecs() +information.append("");information.append("") +information.append("MSG") +information.append(config["default"]["msg"]) + +asciiLuma = asciiLuma.split("\n") +asciiChroma = asciiChroma.split("\n") +asciiMaxLength = 0 +for line in asciiLuma: + line = line.replace("\n","") + length = len(line) + if (length > asciiMaxLength): asciiMaxLength = length +asciiEmpty = "" +while len(asciiEmpty) < asciiMaxLength: + asciiEmpty = asciiEmpty + " " + +index = 0 +asciiIndex = 0 +length = len(information) +asciiLength = len(asciiLuma) +asciiChromaLength = len(asciiChroma) +colorIndex = 0 +specColors = ["r","g","c","y"] +uncoloredOut = [] + +while index < length: + curLine = "" + infon = information[index] + infod = information[index + 1] + + if asciiIndex < len(asciiLuma): + curLine = asciiLuma[asciiIndex] + else: + curLine = asciiEmpty + while len(curLine) < asciiMaxLength: + curLine = curLine + " " + + if infon != "": + if infon != "RAW": + curLine = curLine + infon + ": " + infod + else: + curLine = curLine + infod + + while len(curLine) > x: + curLine = curLine[:-1] + + uncoloredOut.append(curLine) + index = index + 2 + asciiIndex = asciiIndex + 1 + +while asciiIndex < asciiLength: + curLine = asciiLuma[asciiIndex] + while len(curLine) > x: + curLine = curLine[:-1] + uncoloredOut.append(curLine) + asciiIndex = asciiIndex + 1 + +outLength = len(uncoloredOut) + +coloredOut = [] +asciiIndex = 0 +lastColor = "i" +while asciiIndex < outLength: + line = uncoloredOut[asciiIndex] + chromaLine = asciiChroma[asciiIndex] + + newLine = "" + lineIndex = 0 + lineLength = len(line) + while lineIndex < lineLength: + curColor = "i" + symbol = line[lineIndex] + if lineIndex < len(chromaLine): + curColor = chromaLine[lineIndex] + else: + curColor = "i" + + if not curColor.lower() in colors: + curColor = "i" + + if curColor != lastColor: + if curColor != "i": + colorDef = colorama.Style.RESET_ALL + colors[curColor.lower()] + if curColor.lower() != curColor: colorDef = colorDef + colorama.Style.BRIGHT + symbol = colorDef + symbol + else: + symbol = colorama.Style.RESET_ALL + symbol + lastColor = curColor + + newLine = newLine + symbol + lineIndex = lineIndex + 1 + + coloredOut.append(newLine) + asciiIndex = asciiIndex + 1 +coloredOut[-1] = coloredOut[-1] + colorama.Style.RESET_ALL + +for line in coloredOut: + print(line) \ No newline at end of file