| @@ -31,29 +31,30 @@ def convert(origin, target): | |||||
| cmd = 'ffmpeg -i {0} -c copy {1}'.format(origin, target) | cmd = 'ffmpeg -i {0} -c copy {1}'.format(origin, target) | ||||
| print("cmd:: {0}".format(cmd)) | print("cmd:: {0}".format(cmd)) | ||||
| args = shlex.split(cmd) | args = shlex.split(cmd) | ||||
| status, output = sp.getstatusoutput(cmd) | |||||
| print("status:: {0}, output {1}".format(status, output)) | |||||
| if status ==0: | |||||
| print("{0} convert {1} Success, origin dat will remove!".format(origin, target)) | |||||
| os.remove(origin) | |||||
| else: | |||||
| print("{0} convert fail".format(origin)) | |||||
| #proc = sp.Popen(args, stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE) | |||||
| #answer = b'Overwrite ? [y/N]' | |||||
| #try: | |||||
| # outs, errs = proc.communicate() | |||||
| # print(outs, errs) | |||||
| # print("answer in outs : {0}".format(answer in errs)) | |||||
| # if answer in errs: | |||||
| # print('write y') | |||||
| # # proc.stdin.write(b'y') | |||||
| # if proc.returncode == 0: | |||||
| # print("{0} convert {1} Success, origin dat will remove!".format(origin, target)) | |||||
| # os.remove(origin) | |||||
| # else: | |||||
| # print("{0} convert fail".format(origin)) | |||||
| #except sp.TimeoutExpired: | |||||
| # proc.kill() | |||||
| #status, output = sp.getstatusoutput(cmd) | |||||
| #print("status:: {0}, output {1}".format(status, output)) | |||||
| #if status ==0: | |||||
| # print("{0} convert {1} Success, origin dat will remove!".format(origin, target)) | |||||
| # os.remove(origin) | |||||
| #else: | |||||
| # print("{0} convert fail".format(origin)) | |||||
| proc = sp.Popen(args, stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE) | |||||
| answer = b'Overwrite ? [y/N]' | |||||
| try: | |||||
| outs, errs = proc.communicate() | |||||
| print(outs, errs) | |||||
| print("answer in outs : {0}".format(answer in errs)) | |||||
| if answer in errs: | |||||
| print('write y') | |||||
| continue | |||||
| # proc.stdin.write(b'y') | |||||
| if proc.returncode == 0: | |||||
| print("{0} convert {1} Success, origin dat will remove!".format(origin, target)) | |||||
| os.remove(origin) | |||||
| else: | |||||
| print("{0} convert fail".format(origin)) | |||||
| except sp.TimeoutExpired: | |||||
| proc.kill() | |||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||
| @@ -62,4 +63,4 @@ if __name__ == "__main__": | |||||
| codec = sys.argv[1] | codec = sys.argv[1] | ||||
| # timeout=sys.argv[2] | # timeout=sys.argv[2] | ||||
| print("codec:: {0}".format(codec)) | print("codec:: {0}".format(codec)) | ||||
| list_folder(DAT_FOLDER, TARGET_FOLDER, codec) | |||||
| list_folder(DAT_FOLDER, TARGET_FOLDER, codec) | |||||