Feb-21-2017, 01:24 AM
I cannot for the life of me get 2to3 work for me and I was wondering if anyone would be gracious enough to help me out with it. I would sincerely appreciate it.
(Feb-21-2017, 02:22 AM)micseydel Wrote: [ -> ]Could you elaborate? What reference resources are you using? What exactly did you try? How exactly did it not work?
(Feb-21-2017, 02:22 AM)micseydel Wrote: [ -> ]Could you elaborate? What reference resources are you using? What exactly did you try? How exactly did it not work?
import struct import msvcrt as m import os def wait(): m.getch() def readByte(file): return struct.unpack("B", file.read(1))[0] def readu16le(file): return struct.unpack("<H", file.read(2))[0] def readu32le(file): return struct.unpack("<I", file.read(4))[0] tgas = ["iconTex.tga","bootLogoTex.tga","bootDrcTex.tga","bootTvTex.tga"] dimensions = [[128,128,32],[170,42,32],[854,480,24],[1280,720,24]] for i in range(len(tgas)): tga = tgas[i] dimension = dimensions[i] if os.path.exists(tga): with open(tga,"rb+") as f: header = readu32le(f) if header != 0x00020000: print tga + "is compressed. it cant be compressed!" break f.seek(12) actDimensions = [readu16le(f),readu16le(f),readByte(f)] hasHadBadDiment = False for j in range(len(actDimensions)): if j == 0: type = "width" elif j == 1: type = "height" else: type = "depth" diment = dimension[j] actDiment = actDimensions[j] if diment != actDiment: if not hasHadBadDiment: hasHadBadDiment = True print "dimensions are not valid for: " + tga print type + " is: " + str(actDiment) + " should be: " + str(diment) if hasHadBadDiment: break f.seek(1,1) f.seek(actDimensions[0]*actDimensions[1]*(actDimensions[2]/8),1) f.write("\x00\x00\x00\x00\x00\x00\x00\x00TRUEVISION-XFILE\x2E\x00") else: print tga + " could not be found!" print "All TGA's verified!" print "press any key to exit..." #todo verifiy bootovie.h264 wait()
import struct import msvcrt as m import os def wait(): m.getch() def readByte(file): return struct.unpack("B", file.read(1))[0] def readu16le(file): return struct.unpack("<H", file.read(2))[0] def readu32le(file): return struct.unpack("<I", file.read(4))[0] tgas = ["iconTex.tga","bootLogoTex.tga","bootDrcTex.tga","bootTvTex.tga"] dimensions = [[128,128,32],[170,42,32],[854,480,24],[1280,720,24]] for i in range(len(tgas)): tga = tgas[i] dimension = dimensions[i] if os.path.exists(tga): with open(tga,"rb+") as f: header = readu32le(f) if header != 0x00020000: print(tga + "is compressed. it cant be compressed!") break f.seek(12) actDimensions = [readu16le(f),readu16le(f),readByte(f)] hasHadBadDiment = False for j in range(len(actDimensions)): if j == 0: type = "width" elif j == 1: type = "height" else: type = "depth" diment = dimension[j] actDiment = actDimensions[j] if diment != actDiment: if not hasHadBadDiment: hasHadBadDiment = True print("dimensions are not valid for: " + tga) print(type + " is: " + str(actDiment) + " should be: " + str(diment)) if hasHadBadDiment: break f.seek(1,1) f.seek(actDimensions[0]*actDimensions[1]*(actDimensions[2]/8),1) f.write("\x00\x00\x00\x00\x00\x00\x00\x00TRUEVISION-XFILE\x2E\x00") else: print(tga + " could not be found!") print("All TGA's verified!") print("press any key to exit...") #todo verifiy bootovie.h264 wait()
(Feb-21-2017, 06:29 AM)Skaperen Wrote: [ -> ]and what comes out as py3 code that does not work? (/me not looking at the code, yet)
file
is built-in function in python2 so I would not use it as argument to the functions. Same for type
.file
is gone in python 3. so i wonder how 2to3 will handle that (Feb-21-2017, 08:41 AM)Skaperen Wrote: [ -> ]file
is gone in python 3. so i wonder how 2to3 will handle that
os.path.exists
cannot find the files.