mirror of
https://github.com/MiSTer-devel/Scripts_MiSTer.git
synced 2026-05-17 03:04:34 +00:00
Fixes for mra_rom_check
* Log mra_rom_check output to logfile Since mra_rom_check can create a lot of output, and that output needs to be reviewed carefully, this fix causes to output to simultaneously be directed to a logfile. - 'Scripts/Logs' subdirectory will be created if it does not already exist - log output goes to Logs/mra_rom_check.log, which will be deleted and recreated each time it is run * fixed error reporting with a mismatched rom * Separate messages for missing MAME version Too many MRA files are missing MAME version - these drown out the real issues on the screen and in the logfile - these don't appear to cause issues with the MRAs - It is difficult to actually acquire "correct" data for these -> This update outputs them to a separate logfile and suppresses them from the screen output (can easily be re-enabled later when/if this problem is under control) Co-authored-by: Alan Steremberg <alanswx@users.noreply.github.com> Co-authored-by: Alan Steremberg <alan.steremberg@gmail.com>
This commit is contained in:
90
other_authors/mra_rom_check.sh
Executable file → Normal file
90
other_authors/mra_rom_check.sh
Executable file → Normal file
@@ -32,6 +32,16 @@ def find_mame_folder():
|
||||
|
||||
broken = []
|
||||
|
||||
def output_line(line):
|
||||
print(line)
|
||||
logfile.write(line)
|
||||
logfile.write('\n')
|
||||
|
||||
def output_line_mameversion(line):
|
||||
#print(line)
|
||||
logfile_v.write(line)
|
||||
logfile_v.write('\n')
|
||||
|
||||
def parseMRA(mraFile):
|
||||
working = True
|
||||
tree = ET.parse(mraFile)
|
||||
@@ -51,48 +61,51 @@ def parseMRA(mraFile):
|
||||
if ('zip' in child.attrib):
|
||||
zip=child.attrib['zip']
|
||||
zipfiles = zipfiles+ zip.split('|')
|
||||
#print(zipfiles)
|
||||
#output_line(zipfiles)
|
||||
crclist = []
|
||||
for zipfilename in zipfiles:
|
||||
try:
|
||||
mame_folder=find_mame_folder()
|
||||
zf = zipfile.ZipFile(mame_folder+'/'+zipfilename)
|
||||
for zi in zf.infolist():
|
||||
#print(zi.filename)
|
||||
#print('{:x}'.format(zi.CRC))
|
||||
#print('{0:0{1}x}'.format(zi.CRC,8))
|
||||
#output_line(zi.filename)
|
||||
#output_line('{:x}'.format(zi.CRC))
|
||||
#output_line('{0:0{1}x}'.format(zi.CRC,8))
|
||||
crclist.append('{0:0{1}x}'.format(zi.CRC,8))
|
||||
except:
|
||||
#print('file not found: '+zipfilename)
|
||||
#output_line('file not found: '+zipfilename)
|
||||
if ('filename' in info):
|
||||
info['filename'].append(zipfilename)
|
||||
else:
|
||||
info['filename']=[]
|
||||
info['filename'].append(zipfilename)
|
||||
|
||||
#print(crclist)
|
||||
#output_line(crclist)
|
||||
for item in root.findall('rom/part'):
|
||||
#print(item.attrib)
|
||||
#output_line(item.attrib)
|
||||
if ('crc' in item.attrib):
|
||||
noCRC = False
|
||||
crc=item.attrib['crc']
|
||||
if (crc.lower() in crclist):
|
||||
a=1
|
||||
#print('rom found')
|
||||
#output_line('rom found')
|
||||
else:
|
||||
#print('**ROM NOT FOUND** '+crc)
|
||||
#output_line('**ROM NOT FOUND** '+crc)
|
||||
if (crc in info):
|
||||
info['crc'].append(crc)
|
||||
info['name'].append(item.attrib['name'])
|
||||
else:
|
||||
info['crc']=[]
|
||||
info['name']=[]
|
||||
info['crc'].append(crc)
|
||||
info['name'].append(item.attrib['name'])
|
||||
working = False
|
||||
if not working:
|
||||
broken.append(info)
|
||||
if noCRC and len(zipfiles):
|
||||
print(mraFile+':NO CRC, Could not validate')
|
||||
output_line(mraFile+':NO CRC, Could not validate')
|
||||
if noMameVersion:
|
||||
print(mraFile+':No MameVersion ')
|
||||
output_line_mameversion(mraFile+':No MameVersion ')
|
||||
|
||||
return working
|
||||
|
||||
@@ -100,31 +113,68 @@ def iterateMRAFiles(directory):
|
||||
for filename in os.listdir(directory):
|
||||
if filename.endswith(".mra"):
|
||||
fullname=os.path.join(directory,filename)
|
||||
#print(fullname)
|
||||
#output_line(fullname)
|
||||
try:
|
||||
working=parseMRA(fullname)
|
||||
except:
|
||||
print('Broken XML:'+fullname)
|
||||
output_line('Broken XML:'+fullname)
|
||||
#if not working:
|
||||
# print('Not Working:'+fullname)
|
||||
# output_line('Not Working:'+fullname)
|
||||
|
||||
print("checking /media/fat/_Arcade/")
|
||||
#########################################
|
||||
# Create Logs subdirectory for log output
|
||||
#########################################
|
||||
path = os.getcwd()
|
||||
print ("The current working directory is %s" % path)
|
||||
path = "Logs"
|
||||
|
||||
try:
|
||||
os.mkdir(path)
|
||||
except OSError:
|
||||
print ("Directory %s already exists" % path)
|
||||
else:
|
||||
print ("Successfully created the directory %s " % path)
|
||||
|
||||
#########################################
|
||||
# Create Logs subdirectory for log output
|
||||
#########################################
|
||||
|
||||
logfile = open("Logs/mra_rom_check.log", "w")
|
||||
logfile_v = open("Logs/mra_rom_check_mamever.log", "w")
|
||||
|
||||
output_line("checking /media/fat/_Arcade/")
|
||||
#logfile.write("checking /media/fat/_Arcade/")
|
||||
iterateMRAFiles('/media/fat/_Arcade/')
|
||||
|
||||
for info in broken:
|
||||
#print(info)
|
||||
missingzips=""
|
||||
wrongcrc=""
|
||||
if ('filename' in info):
|
||||
for fname in info['filename']:
|
||||
missingzips=missingzips+fname+","
|
||||
print("missing: "+missingzips+" for: "+info['mraname'])
|
||||
if ('name' in info):
|
||||
for name in info['name']:
|
||||
wrongcrc=wrongcrc+name+","
|
||||
errorstr = ""
|
||||
if (len(missingzips)):
|
||||
errorstr=errorstr+" missing zip: "+missingzips+" "
|
||||
if (len(wrongcrc)):
|
||||
errorstr=errorstr+" wrong crc for: "+wrongcrc+" "
|
||||
|
||||
output_line(errorstr+" for: "+info['mraname'])
|
||||
|
||||
|
||||
#working=parseMRA('Xevious.mra')
|
||||
#working=parseMRA('Tapper.mra')
|
||||
#print('Working:'+str(working))
|
||||
#output_line('Working:'+str(working))
|
||||
#working=parseMRA('Asteroids.mra')
|
||||
#print('Working:'+str(working))
|
||||
#output_line('Working:'+str(working))
|
||||
#working=parseMRA('Alien Arena.mra')
|
||||
#print('Working:'+str(working))
|
||||
#output_line('Working:'+str(working))
|
||||
#working=parseMRA('Xevious.mra')
|
||||
#print('Working:'+str(working))
|
||||
#output_line('Working:'+str(working))
|
||||
|
||||
logfile.close()
|
||||
logfile_v.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user