mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Python tool to validate configs (using MakePbo)
This commit is contained in:
parent
0397b3f9f4
commit
abe936065e
118
tools/config_validator.py
Normal file
118
tools/config_validator.py
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
#by PabstMirror - python script to verify all addons using MakePbo's lint checking and extFile Checking
|
||||||
|
#Arguments (eg: `config_validator.py full`):
|
||||||
|
#full dump full deRaped config of problem
|
||||||
|
#skipExt skips checking external file references
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
import timeit
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
|
||||||
|
######## GLOBALS #########
|
||||||
|
MAINPREFIX = "z"
|
||||||
|
PREFIX = "ace_"
|
||||||
|
##########################
|
||||||
|
|
||||||
|
def Fract_Sec(s):
|
||||||
|
temp = float()
|
||||||
|
temp = float(s) / (60*60*24)
|
||||||
|
d = int(temp)
|
||||||
|
temp = (temp - d) * 24
|
||||||
|
h = int(temp)
|
||||||
|
temp = (temp - h) * 60
|
||||||
|
m = int(temp)
|
||||||
|
temp = (temp - m) * 60
|
||||||
|
sec = temp
|
||||||
|
return d,h,m,sec
|
||||||
|
|
||||||
|
def CheckPBO(p,makePboArgs,errors):
|
||||||
|
try:
|
||||||
|
subprocess.run([
|
||||||
|
"makepbo",
|
||||||
|
makePboArgs,
|
||||||
|
"-@={}\\{}\\addons\\{}".format(MAINPREFIX,PREFIX.rstrip("_"),p),
|
||||||
|
p,
|
||||||
|
"{}{}.pbo".format(PREFIX,p)
|
||||||
|
], stdin=None, input=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print("!! Problem With {} ret {} !!".format(p, e.returncode))
|
||||||
|
print(" stderr: {}".format(e.stderr))
|
||||||
|
errors.append(p)
|
||||||
|
else:
|
||||||
|
print(" Checked ok {}".format(p))
|
||||||
|
return
|
||||||
|
|
||||||
|
def fullDump(p):
|
||||||
|
try:
|
||||||
|
subprocess.run([
|
||||||
|
"makepbo",
|
||||||
|
"-PQGs", #Q Lint only - Gs Check external references and show deRap - P dont pause
|
||||||
|
"-@={}\\{}\\addons\\{}".format(MAINPREFIX,PREFIX.rstrip("_"),p),
|
||||||
|
p,
|
||||||
|
"{}{}.pbo".format(PREFIX,p)
|
||||||
|
], stdin=None, input=None, check=True)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
input("Press Enter to continue...")
|
||||||
|
return
|
||||||
|
|
||||||
|
def main(argv):
|
||||||
|
print("""
|
||||||
|
####################
|
||||||
|
# ACE3 Config Check #
|
||||||
|
####################
|
||||||
|
""")
|
||||||
|
|
||||||
|
start_time = timeit.default_timer()
|
||||||
|
|
||||||
|
scriptpath = os.path.realpath(__file__)
|
||||||
|
projectpath = os.path.dirname(os.path.dirname(scriptpath))
|
||||||
|
addonspath = os.path.join(projectpath, "addons")
|
||||||
|
|
||||||
|
os.chdir(addonspath)
|
||||||
|
|
||||||
|
#Q Lint only - G Check external references - P dont pause (Gs) does full derap
|
||||||
|
makePboArgs = "-PQG"
|
||||||
|
if "skipExt" in argv:
|
||||||
|
print("Skipping External Files Check");
|
||||||
|
makePboArgs = "-PQ"
|
||||||
|
|
||||||
|
errors = []
|
||||||
|
|
||||||
|
for p in os.listdir(addonspath):
|
||||||
|
path = os.path.join(addonspath, p)
|
||||||
|
if not os.path.isdir(path):
|
||||||
|
continue
|
||||||
|
if p[0] == ".":
|
||||||
|
continue
|
||||||
|
|
||||||
|
# t = threading.Thread(target=CheckPBO, args=(p,makePboArgs,errors))
|
||||||
|
# t.start()
|
||||||
|
CheckPBO(p,makePboArgs,errors)
|
||||||
|
|
||||||
|
|
||||||
|
# for t in threading.enumerate():
|
||||||
|
# if t is threading.currentThread():
|
||||||
|
# continue
|
||||||
|
# t.join()
|
||||||
|
|
||||||
|
d,h,m,s = Fract_Sec(timeit.default_timer() - start_time)
|
||||||
|
print("\n# Done with {0} errrors [took: {1:2}h {2:2}m {3:4.5f}s]".format(len(errors),h,m,s))
|
||||||
|
|
||||||
|
if (len(errors) > 0):
|
||||||
|
if "full" in argv:
|
||||||
|
input("Dumping Full DeRap: Press Enter to continue...")
|
||||||
|
for p in errors:
|
||||||
|
fullDump(p)
|
||||||
|
else:
|
||||||
|
print("use 'full' arg to show derap")
|
||||||
|
|
||||||
|
ret = len(errors)
|
||||||
|
print("return {}".format(ret))
|
||||||
|
return ret
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main(sys.argv)
|
Loading…
Reference in New Issue
Block a user