2016-01-10 20:46:45 +00:00
|
|
|
#!/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 time
|
|
|
|
|
|
|
|
######## GLOBALS #########
|
2016-01-14 23:42:35 +00:00
|
|
|
MAINPREFIX = "Z"
|
|
|
|
PREFIX = "ACE"
|
2016-01-10 20:46:45 +00:00
|
|
|
##########################
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2017-09-21 17:41:48 +00:00
|
|
|
def CheckPBO(p,useMakePbo,checkExternalFiles,errors):
|
2016-01-10 20:46:45 +00:00
|
|
|
try:
|
2017-09-21 17:41:48 +00:00
|
|
|
if useMakePbo:
|
|
|
|
makePboArgs = "-PGU"
|
|
|
|
if not checkExternalFiles:
|
|
|
|
makePboArgs = "-PU"
|
|
|
|
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)
|
|
|
|
else:
|
|
|
|
makePboArgs = "-LEP"
|
|
|
|
if not checkExternalFiles:
|
|
|
|
makePboArgs = "-LP"
|
|
|
|
subprocess.run([
|
|
|
|
"rapify",
|
|
|
|
makePboArgs,
|
|
|
|
p
|
|
|
|
], stdin=None, input=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)
|
|
|
|
|
2016-01-10 20:46:45 +00:00
|
|
|
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))
|
2016-01-14 23:42:35 +00:00
|
|
|
return
|
2016-01-10 20:46:45 +00:00
|
|
|
|
2016-01-14 23:42:35 +00:00
|
|
|
def fullDump(p):
|
2016-01-10 20:46:45 +00:00
|
|
|
try:
|
|
|
|
subprocess.run([
|
|
|
|
"makepbo",
|
2017-09-21 17:41:48 +00:00
|
|
|
"-PGUS", #G Check external references -S show deRap - P dont pause
|
2016-01-10 20:46:45 +00:00
|
|
|
"-@={}\\{}\\addons\\{}".format(MAINPREFIX,PREFIX.rstrip("_"),p),
|
|
|
|
p,
|
2016-01-14 23:42:35 +00:00
|
|
|
"{}_{}.pbo".format(PREFIX,p)
|
2016-01-10 20:46:45 +00:00
|
|
|
], stdin=None, input=None, check=True)
|
2016-01-14 23:42:35 +00:00
|
|
|
except subprocess.CalledProcessError as e:
|
2016-01-10 20:46:45 +00:00
|
|
|
input("Press Enter to continue...")
|
2016-01-14 23:42:35 +00:00
|
|
|
return
|
|
|
|
|
2016-01-10 20:46:45 +00:00
|
|
|
def main(argv):
|
|
|
|
print("""
|
|
|
|
####################
|
|
|
|
# ACE3 Config Check #
|
|
|
|
####################
|
|
|
|
""")
|
|
|
|
|
|
|
|
start_time = timeit.default_timer()
|
|
|
|
|
2016-01-14 23:42:35 +00:00
|
|
|
addonspath = os.path.join("P:\\",MAINPREFIX,PREFIX,"addons")
|
2016-01-10 20:46:45 +00:00
|
|
|
|
2016-01-14 23:42:35 +00:00
|
|
|
print("Switching to dir: {}".format(addonspath))
|
|
|
|
try:
|
|
|
|
os.chdir(addonspath)
|
|
|
|
except:
|
|
|
|
raise Exception("Failed to switch to addon dir on P:")
|
2016-01-10 20:46:45 +00:00
|
|
|
|
2017-09-21 17:41:48 +00:00
|
|
|
useMakePbo = False
|
|
|
|
checkExternalFiles = True
|
|
|
|
|
2016-01-10 20:46:45 +00:00
|
|
|
if "skipExt" in argv:
|
|
|
|
print("Skipping External Files Check");
|
2017-09-21 17:41:48 +00:00
|
|
|
checkExternalFiles = False
|
|
|
|
if "make" in argv:
|
|
|
|
# will check more files like RTM and RVMats but twice as slow
|
|
|
|
# This also actually builds a pbo (in same spot as build.py)
|
|
|
|
print("Using makePbo to verify all files");
|
|
|
|
useMakePbo = True
|
2016-01-10 20:46:45 +00:00
|
|
|
|
|
|
|
errors = []
|
2016-01-14 23:42:35 +00:00
|
|
|
|
2016-01-10 20:46:45 +00:00
|
|
|
for p in os.listdir(addonspath):
|
|
|
|
path = os.path.join(addonspath, p)
|
|
|
|
if not os.path.isdir(path):
|
|
|
|
continue
|
|
|
|
if p[0] == ".":
|
|
|
|
continue
|
2017-09-21 17:41:48 +00:00
|
|
|
CheckPBO(p,useMakePbo,checkExternalFiles,errors)
|
2016-01-10 20:46:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
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))
|
2016-01-14 23:42:35 +00:00
|
|
|
|
2016-01-10 20:46:45 +00:00
|
|
|
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")
|
2016-01-14 23:42:35 +00:00
|
|
|
|
2016-01-10 20:46:45 +00:00
|
|
|
ret = len(errors)
|
|
|
|
print("return {}".format(ret))
|
|
|
|
return ret
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main(sys.argv)
|