Merge pull request #4 from xperia64/update_to_python3

Update to python3
This commit is contained in:
Zion 2021-12-22 15:29:04 -08:00 committed by GitHub
commit 4b06465458
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 75 additions and 75 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
import os
import ntpath
@ -77,11 +77,11 @@ def runTests(emulator, baseDir):
# Compare output
if compareMethod == COMPARE_TEXT:
result = result.replace('\r\n', '\n')
result = result.replace(b'\r\n', b'\n')
if result == expected.read():
print " - Success: ", relProjectFolder
print(" - Success: ", relProjectFolder)
else:
print " - Error: ", relProjectFolder
print(" - Error: ", relProjectFolder)
errors = True
# Delete output file if necessary
@ -90,18 +90,18 @@ def runTests(emulator, baseDir):
# Return errors
if errors:
print "Some tests failed!"
print("Some tests failed!")
exit(1)
else:
print "All tests succeeded!"
print("All tests succeeded!")
exit(0)
if __name__ == '__main__':
if len(sys.argv) <= 1:
print 'PS3 Autotests: Tests, benchmarks and demos for emulators'
print 'Usage: run-tests.py [arguments] path/to/emulator.exe'
print 'Arguments: (none available)'
print('PS3 Autotests: Tests, benchmarks and demos for emulators')
print('Usage: run-tests.py [arguments] path/to/emulator.exe')
print('Arguments: (none available)')
else:
baseDir = os.path.dirname(os.path.abspath(__file__)).replace('\\', '/')
emulator = sys.argv[len(sys.argv) - 1]

View File

@ -54,8 +54,8 @@ for y in range(img.size[0])[::-1]:
ARGB |= (pix[x,y][0] & 0xF8) << 7
ARGB |= (pix[x,y][1] & 0xF8) << 2
ARGB |= (pix[x,y][2] & 0xF8) >> 3
w.write(chr((ARGB >> 8) & 0xFF))
w.write(chr((ARGB >> 0) & 0xFF))
w.write(bytes([(ARGB >> 8) & 0xFF]))
w.write(bytes([(ARGB >> 0) & 0xFF]))
w.close()
@ -65,8 +65,8 @@ for y in range(img.size[0])[::-1]:
for x in range(img.size[1]):
AR = (pix[x,y][3] & 0xF0) | (pix[x,y][0] >> 4)
GB = (pix[x,y][1] & 0xF0) | (pix[x,y][2] >> 4)
w.write(chr(AR))
w.write(chr(GB))
w.write(bytes([AR]))
w.write(bytes([GB]))
w.close()
@ -74,10 +74,10 @@ w.close()
w = open("Texture-A8R8G8B8.raw", "wb")
for y in range(img.size[0])[::-1]:
for x in range(img.size[1]):
w.write(chr(pix[x,y][3]))
w.write(chr(pix[x,y][0]))
w.write(chr(pix[x,y][1]))
w.write(chr(pix[x,y][2]))
w.write(bytes([pix[x,y][3]]))
w.write(bytes([pix[x,y][0]]))
w.write(bytes([pix[x,y][1]]))
w.write(bytes([pix[x,y][2]]))
w.close()
@ -85,7 +85,7 @@ w.close()
w = open("Texture-B8.raw", "wb")
for y in range(img.size[0])[::-1]:
for x in range(img.size[1]):
w.write(chr(pix[x,y][2]))
w.write(bytes([pix[x,y][2]]))
w.close()
@ -93,12 +93,12 @@ w.close()
w = open("Texture-COMPRESSED_B8R8_G8R8.raw", "wb")
for y in range(img.size[0])[::-1]:
for x in range(0, img.size[1], 2):
b = (pix[x + 0, y][2] + pix[x + 1, y][2]) / 2
g = (pix[x + 0, y][1] + pix[x + 1, y][1]) / 2
w.write(chr(b))
w.write(chr(pix[x + 1, y][0]))
w.write(chr(g))
w.write(chr(pix[x + 0, y][0]))
b = (pix[x + 0, y][2] + pix[x + 1, y][2]) // 2
g = (pix[x + 0, y][1] + pix[x + 1, y][1]) // 2
w.write(bytes([b]))
w.write(bytes([pix[x + 1, y][0]]))
w.write(bytes([g]))
w.write(bytes([pix[x + 0, y][0]]))
w.close()
@ -106,12 +106,12 @@ w.close()
w = open("Texture-COMPRESSED_R8B8_R8G8.raw", "wb")
for y in range(img.size[0])[::-1]:
for x in range(0, img.size[1], 2):
b = (pix[x + 0, y][2] + pix[x + 1, y][2]) / 2
g = (pix[x + 0, y][1] + pix[x + 1, y][1]) / 2
w.write(chr(pix[x + 1, y][0]))
w.write(chr(b))
w.write(chr(pix[x + 0, y][0]))
w.write(chr(g))
b = (pix[x + 0, y][2] + pix[x + 1, y][2]) // 2
g = (pix[x + 0, y][1] + pix[x + 1, y][1]) // 2
w.write(bytes([pix[x + 1, y][0]]))
w.write(bytes([b]))
w.write(bytes([pix[x + 0, y][0]]))
w.write(bytes([g]))
w.close()
@ -119,8 +119,8 @@ w.close()
w = open("Texture-COMPRESSED_HILO8.raw", "wb")
for y in range(img.size[0])[::-1]:
for x in range(0, img.size[1]):
w.write(chr(255-y))
w.write(chr(x))
w.write(bytes([255-y]))
w.write(bytes([x]))
w.close()
@ -128,8 +128,8 @@ w.close()
w = open("Texture-COMPRESSED_HILO_S8.raw", "wb")
for y in range(img.size[0])[::-1]:
for x in range(0, img.size[1]):
w.write(chr(255-y))
w.write(chr(x))
w.write(bytes([255-y]))
w.write(bytes([x]))
w.close()
@ -141,8 +141,8 @@ for y in range(img.size[0])[::-1]:
ARGB |= (pix[x,y][0] & 0xF8) << 7
ARGB |= (pix[x,y][1] & 0xF8) << 2
ARGB |= (pix[x,y][2] & 0xF8) >> 3
w.write(chr((ARGB >> 8) & 0xFF))
w.write(chr((ARGB >> 0) & 0xFF))
w.write(bytes([(ARGB >> 8) & 0xFF]))
w.write(bytes([(ARGB >> 0) & 0xFF]))
w.close()
@ -150,10 +150,10 @@ w.close()
w = open("Texture-D8R8G8B8.raw", "wb")
for y in range(img.size[0])[::-1]:
for x in range(img.size[1]):
w.write(chr(0x00))
w.write(chr(pix[x,y][0]))
w.write(chr(pix[x,y][1]))
w.write(chr(pix[x,y][2]))
w.write(b'\x00')
w.write(bytes([pix[x,y][0]]))
w.write(bytes([pix[x,y][1]]))
w.write(bytes([pix[x,y][2]]))
w.close()
@ -161,8 +161,8 @@ w.close()
w = open("Texture-G8B8.raw", "wb")
for y in range(img.size[0])[::-1]:
for x in range(img.size[1]):
w.write(chr(pix[x,y][1]))
w.write(chr(pix[x,y][2]))
w.write(bytes([pix[x,y][1]]))
w.write(bytes([pix[x,y][2]]))
w.close()
@ -174,8 +174,8 @@ for y in range(img.size[0])[::-1]:
ARGB |= (pix[x,y][1] & 0xF8) << 3
ARGB |= (pix[x,y][2] & 0xF8) >> 2
ARGB |= (pix[x,y][3] & 0x80) >> 7
w.write(chr((ARGB >> 8) & 0xFF))
w.write(chr((ARGB >> 0) & 0xFF))
w.write(bytes([(ARGB >> 8) & 0xFF]))
w.write(bytes([(ARGB >> 0) & 0xFF]))
w.close()
@ -186,8 +186,8 @@ for y in range(img.size[0])[::-1]:
ARGB = (pix[x,y][0] & 0xF8) << 8
ARGB |= (pix[x,y][1] & 0xFC) << 3
ARGB |= (pix[x,y][2] & 0xF8) >> 3
w.write(chr((ARGB >> 8) & 0xFF))
w.write(chr((ARGB >> 0) & 0xFF))
w.write(bytes([(ARGB >> 8) & 0xFF]))
w.write(bytes([(ARGB >> 0) & 0xFF]))
w.close()
@ -198,8 +198,8 @@ for y in range(img.size[0])[::-1]:
ARGB = (pix[x,y][0] & 0xFC) << 8
ARGB |= (pix[x,y][1] & 0xF8) << 2
ARGB |= (pix[x,y][2] & 0xF8) >> 3
w.write(chr((ARGB >> 8) & 0xFF))
w.write(chr((ARGB >> 0) & 0xFF))
w.write(bytes([(ARGB >> 8) & 0xFF]))
w.write(bytes([(ARGB >> 0) & 0xFF]))
w.close()
@ -211,14 +211,14 @@ for y in range(img.size[0])[::-1]:
Z = FP32toFP16(float(pix[x,y][1]/255.0))
Y = FP32toFP16(float(pix[x,y][2]/255.0))
X = FP32toFP16(float(pix[x,y][3]/255.0))
w.write(chr(W >> 8))
w.write(chr(W & 0xFF))
w.write(chr(Z >> 8))
w.write(chr(Z & 0xFF))
w.write(chr(Y >> 8))
w.write(chr(Y & 0xFF))
w.write(chr(X >> 8))
w.write(chr(X & 0xFF))
w.write(bytes([W >> 8]))
w.write(bytes([W & 0xFF]))
w.write(bytes([Z >> 8]))
w.write(bytes([Z & 0xFF]))
w.write(bytes([Y >> 8]))
w.write(bytes([Y & 0xFF]))
w.write(bytes([X >> 8]))
w.write(bytes([X & 0xFF]))
w.close()
@ -226,8 +226,8 @@ w.close()
w = open("Texture-X16.raw", "wb")
for y in range(img.size[0])[::-1]:
for x in range(img.size[1]):
w.write(chr(pix[x,y][3]))
w.write('\x00')
w.write(bytes([pix[x,y][3]]))
w.write(b'\x00')
w.close()
@ -235,10 +235,10 @@ w.close()
w = open("Texture-Y16_X16.raw", "wb")
for y in range(img.size[0])[::-1]:
for x in range(img.size[1]):
w.write(chr(pix[x,y][2]))
w.write('\x00')
w.write(chr(pix[x,y][3]))
w.write('\x00')
w.write(bytes([pix[x,y][2]]))
w.write(b'\x00')
w.write(bytes([pix[x,y][3]]))
w.write(b'\x00')
w.close()
@ -248,8 +248,8 @@ for y in range(img.size[0])[::-1]:
for x in range(img.size[1]):
Y = FP32toFP16(float(pix[x,y][2]/255.0))
X = FP32toFP16(float(pix[x,y][3]/255.0))
w.write(chr(Y >> 8))
w.write(chr(Y & 0xFF))
w.write(chr(X >> 8))
w.write(chr(X & 0xFF))
w.write(bytes([Y >> 8]))
w.write(bytes([Y & 0xFF]))
w.write(bytes([X >> 8]))
w.write(bytes([X & 0xFF]))
w.close()

View File

@ -3,27 +3,27 @@ import sys
def main():
if len(sys.argv) <= 2:
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"
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):
print "[!] Input file does not exist"
print("[!] Input file does not exist")
return False
f = open(inputFile, 'rb')
w = open(outputFile, 'wb')
data = f.read()
data = data[data.find("/app_home/"):]
data = data[data.find("\x0D\x0A")+2:]
data = data[:data.rindex("END LOG")-12]
data = data.replace("\x0D\x0A", "\x0A")
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()