1
0
mirror of https://github.com/RPCS3/ps3autotests.git synced 2024-09-19 15:11:44 +02:00
ps3autotests/utils/convert-ps3-output.py

33 lines
868 B
Python
Raw Normal View History

import os
import sys
def main():
if len(sys.argv) <= 2:
2021-12-22 22:02:27 +01:00
print("This script generates the .expected file from your PS3's debug logs.")
print("")
print("Usage: convert-ps3-output.py <input> <output>")
print("Example: convert-ps3-output.py hello_world.log hello_world.expected")
return False
#Parse and check arguments
inputFile = sys.argv[1]
outputFile = sys.argv[2]
if not os.path.isfile(inputFile):
2021-12-22 22:02:27 +01:00
print("[!] Input file does not exist")
return False
f = open(inputFile, 'rb')
w = open(outputFile, 'wb')
data = f.read()
2021-12-22 22:02:27 +01:00
data = data[data.find(b"/app_home/"):]
data = data[data.find(b"\x0D\x0A")+2:]
data = data[:data.rindex(b"END LOG")-12]
data = data.replace(b"\x0D\x0A", b"\x0A")
w.write(data)
w.close()
if __name__ == "__main__":
main()