Loading parse_commands.py +82 −48 Original line number Diff line number Diff line Loading @@ -15,9 +15,11 @@ if __name__ == '__main__': input = args.input txt_file = args.txt_file TESTV_PATH='$TESTV_PATH/' REF_PATH='$REF_PATH/' CUT_PATH='$CUT_PATH/' TESTV_PATH='$TESTV_PATH' REF_PATH='$REF_PATH' CUT_PATH='$CUT_PATH' here = Path(__file__).parent.resolve() cmds_enc=[] cmds_dec=[] Loading @@ -40,19 +42,20 @@ if __name__ == '__main__': with open('enc_header.txt','r') as header: outfile.write(header.read()) for cmd in cmds_enc: arg1 = cmd.split()[0] root_folder = arg1[0:arg1.find("ivas-codec/")+10] cmd = cmd.replace(root_folder + r'/IVAS_cod', '$CUT_ENC_BIN') cmd = cmd.replace(r'\\', '/') cmd = cmd.replace(root_folder + r'/scripts/', TESTV_PATH) cmd = cmd.replace('scripts/', TESTV_PATH) # To catch relative paths cmd = cmd.replace(root_folder + r'/tests/', CUT_PATH ) if not "pca" in cmd: args = [] for arg in cmd.split(): # Adjust file arguments, pass other arguments as they are if path.exists(arg): arg = path.relpath(arg).replace('\\','/') arg = re.sub('IVAS_cod(.exe)?', '$CUT_ENC_BIN', arg) arg = re.sub('scripts', TESTV_PATH, arg) arg = re.sub('tests', CUT_PATH, arg) args.append(arg) cmd = ' '.join(args) outfile.write(cmd+'\n') bts = re.search(r"\s(([\S]+)(.bts|.192|.pkt|.fer))$", cmd) if bts: outfile.write('$DIFF_BIN '+bts.group(1).replace(CUT_PATH + r'dut',REF_PATH + r'ref')+' '+bts.group(1)+' >> $LOG_FILE 2>&1\n') outfile.write('$DIFF_BIN '+bts.group(1).replace(CUT_PATH + r'/dut',REF_PATH + r'/ref')+' '+bts.group(1)+' >> $LOG_FILE 2>&1\n') outfile.write('\n') with open('script_footer.txt','r') as footer: outfile.write(footer.read()) Loading @@ -64,32 +67,51 @@ if __name__ == '__main__': outfile_jbm.write(header.read()) for cmd in cmds_dec: absolute_out = re.search(r"\s(([\S]+)(.wav))$", cmd) arg1 = cmd.split()[0] root_folder = arg1[0:arg1.find("ivas-codec/")+10] cmd = cmd.replace(root_folder + r'/IVAS_dec', '$CUT_DEC_BIN') cmd = cmd.replace(r'\\', '/') cmd = cmd.replace(root_folder + r'/scripts/', TESTV_PATH) cmd = cmd.replace('scripts/', TESTV_PATH) # To catch relative paths inputs = cmd.count(root_folder) - 1 args = [] inputs = sum([1 if path.exists(a) else 0 for a in cmd.split()]) - 2 # One is the exec, one is the output, rest is inputs for arg in cmd.split(): # Adjust file arguments, pass other arguments as they are if path.exists(arg): arg = path.relpath(arg).replace('\\','/') arg = re.sub('IVAS_dec(.exe)?', '$CUT_DEC_BIN', arg) arg = re.sub('scripts', TESTV_PATH, arg) if ".fer " in cmd: cmd = cmd.replace(root_folder + r'/tests/ref', REF_PATH + r'ref', 1) arg = re.sub('tests/ref', REF_PATH + r'/ref', arg) else: cmd = cmd.replace(root_folder + r'/tests/dut', REF_PATH + r'ref', inputs) cmd = cmd.replace(root_folder + r'/tests/', CUT_PATH) if inputs > 0: arg, count = re.subn('tests/dut', REF_PATH + r'/ref', arg) inputs = inputs - count arg = re.sub('tests', CUT_PATH, arg) args.append(arg) cmd = ' '.join(args) #arg1 = cmd.split()[0] #root_folder = arg1[0:arg1.find("ivas-codec/")+10] #cmd = cmd.replace(root_folder + r'/IVAS_dec', '$CUT_DEC_BIN') #cmd = cmd.replace(r'\\', '/') #cmd = cmd.replace(root_folder + r'/scripts/', TESTV_PATH) #cmd = cmd.replace('scripts/', TESTV_PATH) # To catch relative paths # inputs = cmd.count(root_folder) - 1 # if ".fer " in cmd: # cmd = cmd.replace(root_folder + r'/tests/ref', REF_PATH + r'ref', 1) # else: # cmd = cmd.replace(root_folder + r'/tests/dut', REF_PATH + r'ref', inputs) # cmd = cmd.replace(root_folder + r'/tests/', CUT_PATH) if 'VOIP' in cmd: outfile = outfile_jbm else: outfile = outfile_dec if not "pca" in cmd and not "stvFOA32c4chn_0.004.wav" in cmd and not "stvFOA32c4chn_0.004.wav" in cmd: outfile.write(cmd+'\n') out = re.search(r"\s(([\S]+)(.wav))$", cmd) if out: diff_cmds=[] for output in glob.glob(absolute_out.group(1) + '*'): output = output.replace(root_folder + r'/tests/', CUT_PATH) diff_cmds.append('$DIFF_BIN '+output.replace(CUT_PATH + r'dut',REF_PATH + r'ref')+' '+output+' >> $LOG_FILE 2>&1') output = path.relpath(output).replace('\\','/') output = re.sub('tests', CUT_PATH, output) diff_cmds.append('$DIFF_BIN '+output.replace(CUT_PATH + r'/dut',REF_PATH + r'/ref')+' '+output+' >> $LOG_FILE 2>&1') outfile.write(('; ').join(diff_cmds)) outfile.write('\n\n') with open('script_footer.txt','r') as footer: Loading @@ -101,21 +123,33 @@ if __name__ == '__main__': with open('rend_header.txt','r') as header: outfile.write(header.read()) for cmd in cmds_rend: arg1 = cmd.split()[0] root_folder = arg1[0:arg1.find("ivas-codec/")+10] cmd = cmd.replace(r'\\', '/') cmd = cmd.replace(root_folder + r'/IVAS_rend', '$CUT_REND_BIN') cmd = cmd.replace(root_folder + r'/scripts/', TESTV_PATH) cmd = cmd.replace(root_folder + r'/tests/renderer/data/', TESTV_PATH + r'renderer/data/') cmd = cmd.replace(root_folder + r'/tests/', CUT_PATH) args = [] for arg in cmd.split(): # Adjust file arguments, pass other arguments as they are if path.exists(arg): arg = path.relpath(arg).replace('\\','/') arg = re.sub('IVAS_rend(.exe)?', '$CUT_REND_BIN', arg) arg = re.sub('scripts', TESTV_PATH, arg) arg = re.sub('tests/renderer/data', TESTV_PATH + r'renderer/data/', arg) arg = re.sub('tests', CUT_PATH, arg) args.append(arg) cmd = ' '.join(args) # arg1 = cmd.split()[0] # root_folder = arg1[0:arg1.find("ivas-codec/")+10] # cmd = cmd.replace(r'\\', '/') # cmd = cmd.replace(root_folder + r'/IVAS_rend', '$CUT_REND_BIN') # cmd = cmd.replace(root_folder + r'/scripts/', TESTV_PATH) # cmd = cmd.replace(root_folder + r'/tests/renderer/data/', TESTV_PATH + r'renderer/data/') # cmd = cmd.replace(root_folder + r'/tests/', CUT_PATH) if "cut" in cmd: outfile.write(cmd+'\n') out = re.search(r"-o\s(([\S]+)(.wav|.raw|.pcm))", cmd) if out and "cut" in out.group(1): outfile.write('$DIFF_BIN '+out.group(1).replace(CUT_PATH + r'renderer/cut',REF_PATH + r'renderer/ref')+' '+out.group(1)+' >> $LOG_FILE 2>&1\n') outfile.write('$DIFF_BIN '+out.group(1).replace(CUT_PATH + r'/renderer/cut',REF_PATH + r'/renderer/ref')+' '+out.group(1)+' >> $LOG_FILE 2>&1\n') outfile.write('\n') with open('script_footer.txt','r') as footer: outfile.write(footer.read()) No newline at end of file Loading
parse_commands.py +82 −48 Original line number Diff line number Diff line Loading @@ -15,9 +15,11 @@ if __name__ == '__main__': input = args.input txt_file = args.txt_file TESTV_PATH='$TESTV_PATH/' REF_PATH='$REF_PATH/' CUT_PATH='$CUT_PATH/' TESTV_PATH='$TESTV_PATH' REF_PATH='$REF_PATH' CUT_PATH='$CUT_PATH' here = Path(__file__).parent.resolve() cmds_enc=[] cmds_dec=[] Loading @@ -40,19 +42,20 @@ if __name__ == '__main__': with open('enc_header.txt','r') as header: outfile.write(header.read()) for cmd in cmds_enc: arg1 = cmd.split()[0] root_folder = arg1[0:arg1.find("ivas-codec/")+10] cmd = cmd.replace(root_folder + r'/IVAS_cod', '$CUT_ENC_BIN') cmd = cmd.replace(r'\\', '/') cmd = cmd.replace(root_folder + r'/scripts/', TESTV_PATH) cmd = cmd.replace('scripts/', TESTV_PATH) # To catch relative paths cmd = cmd.replace(root_folder + r'/tests/', CUT_PATH ) if not "pca" in cmd: args = [] for arg in cmd.split(): # Adjust file arguments, pass other arguments as they are if path.exists(arg): arg = path.relpath(arg).replace('\\','/') arg = re.sub('IVAS_cod(.exe)?', '$CUT_ENC_BIN', arg) arg = re.sub('scripts', TESTV_PATH, arg) arg = re.sub('tests', CUT_PATH, arg) args.append(arg) cmd = ' '.join(args) outfile.write(cmd+'\n') bts = re.search(r"\s(([\S]+)(.bts|.192|.pkt|.fer))$", cmd) if bts: outfile.write('$DIFF_BIN '+bts.group(1).replace(CUT_PATH + r'dut',REF_PATH + r'ref')+' '+bts.group(1)+' >> $LOG_FILE 2>&1\n') outfile.write('$DIFF_BIN '+bts.group(1).replace(CUT_PATH + r'/dut',REF_PATH + r'/ref')+' '+bts.group(1)+' >> $LOG_FILE 2>&1\n') outfile.write('\n') with open('script_footer.txt','r') as footer: outfile.write(footer.read()) Loading @@ -64,32 +67,51 @@ if __name__ == '__main__': outfile_jbm.write(header.read()) for cmd in cmds_dec: absolute_out = re.search(r"\s(([\S]+)(.wav))$", cmd) arg1 = cmd.split()[0] root_folder = arg1[0:arg1.find("ivas-codec/")+10] cmd = cmd.replace(root_folder + r'/IVAS_dec', '$CUT_DEC_BIN') cmd = cmd.replace(r'\\', '/') cmd = cmd.replace(root_folder + r'/scripts/', TESTV_PATH) cmd = cmd.replace('scripts/', TESTV_PATH) # To catch relative paths inputs = cmd.count(root_folder) - 1 args = [] inputs = sum([1 if path.exists(a) else 0 for a in cmd.split()]) - 2 # One is the exec, one is the output, rest is inputs for arg in cmd.split(): # Adjust file arguments, pass other arguments as they are if path.exists(arg): arg = path.relpath(arg).replace('\\','/') arg = re.sub('IVAS_dec(.exe)?', '$CUT_DEC_BIN', arg) arg = re.sub('scripts', TESTV_PATH, arg) if ".fer " in cmd: cmd = cmd.replace(root_folder + r'/tests/ref', REF_PATH + r'ref', 1) arg = re.sub('tests/ref', REF_PATH + r'/ref', arg) else: cmd = cmd.replace(root_folder + r'/tests/dut', REF_PATH + r'ref', inputs) cmd = cmd.replace(root_folder + r'/tests/', CUT_PATH) if inputs > 0: arg, count = re.subn('tests/dut', REF_PATH + r'/ref', arg) inputs = inputs - count arg = re.sub('tests', CUT_PATH, arg) args.append(arg) cmd = ' '.join(args) #arg1 = cmd.split()[0] #root_folder = arg1[0:arg1.find("ivas-codec/")+10] #cmd = cmd.replace(root_folder + r'/IVAS_dec', '$CUT_DEC_BIN') #cmd = cmd.replace(r'\\', '/') #cmd = cmd.replace(root_folder + r'/scripts/', TESTV_PATH) #cmd = cmd.replace('scripts/', TESTV_PATH) # To catch relative paths # inputs = cmd.count(root_folder) - 1 # if ".fer " in cmd: # cmd = cmd.replace(root_folder + r'/tests/ref', REF_PATH + r'ref', 1) # else: # cmd = cmd.replace(root_folder + r'/tests/dut', REF_PATH + r'ref', inputs) # cmd = cmd.replace(root_folder + r'/tests/', CUT_PATH) if 'VOIP' in cmd: outfile = outfile_jbm else: outfile = outfile_dec if not "pca" in cmd and not "stvFOA32c4chn_0.004.wav" in cmd and not "stvFOA32c4chn_0.004.wav" in cmd: outfile.write(cmd+'\n') out = re.search(r"\s(([\S]+)(.wav))$", cmd) if out: diff_cmds=[] for output in glob.glob(absolute_out.group(1) + '*'): output = output.replace(root_folder + r'/tests/', CUT_PATH) diff_cmds.append('$DIFF_BIN '+output.replace(CUT_PATH + r'dut',REF_PATH + r'ref')+' '+output+' >> $LOG_FILE 2>&1') output = path.relpath(output).replace('\\','/') output = re.sub('tests', CUT_PATH, output) diff_cmds.append('$DIFF_BIN '+output.replace(CUT_PATH + r'/dut',REF_PATH + r'/ref')+' '+output+' >> $LOG_FILE 2>&1') outfile.write(('; ').join(diff_cmds)) outfile.write('\n\n') with open('script_footer.txt','r') as footer: Loading @@ -101,21 +123,33 @@ if __name__ == '__main__': with open('rend_header.txt','r') as header: outfile.write(header.read()) for cmd in cmds_rend: arg1 = cmd.split()[0] root_folder = arg1[0:arg1.find("ivas-codec/")+10] cmd = cmd.replace(r'\\', '/') cmd = cmd.replace(root_folder + r'/IVAS_rend', '$CUT_REND_BIN') cmd = cmd.replace(root_folder + r'/scripts/', TESTV_PATH) cmd = cmd.replace(root_folder + r'/tests/renderer/data/', TESTV_PATH + r'renderer/data/') cmd = cmd.replace(root_folder + r'/tests/', CUT_PATH) args = [] for arg in cmd.split(): # Adjust file arguments, pass other arguments as they are if path.exists(arg): arg = path.relpath(arg).replace('\\','/') arg = re.sub('IVAS_rend(.exe)?', '$CUT_REND_BIN', arg) arg = re.sub('scripts', TESTV_PATH, arg) arg = re.sub('tests/renderer/data', TESTV_PATH + r'renderer/data/', arg) arg = re.sub('tests', CUT_PATH, arg) args.append(arg) cmd = ' '.join(args) # arg1 = cmd.split()[0] # root_folder = arg1[0:arg1.find("ivas-codec/")+10] # cmd = cmd.replace(r'\\', '/') # cmd = cmd.replace(root_folder + r'/IVAS_rend', '$CUT_REND_BIN') # cmd = cmd.replace(root_folder + r'/scripts/', TESTV_PATH) # cmd = cmd.replace(root_folder + r'/tests/renderer/data/', TESTV_PATH + r'renderer/data/') # cmd = cmd.replace(root_folder + r'/tests/', CUT_PATH) if "cut" in cmd: outfile.write(cmd+'\n') out = re.search(r"-o\s(([\S]+)(.wav|.raw|.pcm))", cmd) if out and "cut" in out.group(1): outfile.write('$DIFF_BIN '+out.group(1).replace(CUT_PATH + r'renderer/cut',REF_PATH + r'renderer/ref')+' '+out.group(1)+' >> $LOG_FILE 2>&1\n') outfile.write('$DIFF_BIN '+out.group(1).replace(CUT_PATH + r'/renderer/cut',REF_PATH + r'/renderer/ref')+' '+out.group(1)+' >> $LOG_FILE 2>&1\n') outfile.write('\n') with open('script_footer.txt','r') as footer: outfile.write(footer.read()) No newline at end of file