python3 stuff

This commit is contained in:
Rene Hopf
2017-09-08 12:51:39 +02:00
parent 9fb4b146fc
commit 626127d842
4 changed files with 14 additions and 14 deletions

View File

@@ -119,7 +119,7 @@ def parse_args():
def dprint(*str):
if args.verbose:
for s in str:
print s,
print (s,)
print
@@ -189,5 +189,5 @@ if __name__ == '__main__':
patch_elf()
except Exception as e:
print e
print (e)
exit(1)

View File

@@ -12,11 +12,11 @@ done = False
for port in serial.tools.list_ports.comports():
if "483:5740" in port[2]:
print "Reseting stmbl at " + port[2]
print ("Reseting stmbl at " + port[2])
stmbl = serial.Serial(port[0])
stmbl.write('bootloader\n')
stmbl.close()
done = True
if not done:
print "No boards found"
print ("No boards found")

View File

@@ -126,11 +126,11 @@ if __name__=='__main__':
# CRC32 with default polynom
crc = CRC32().calc(arg[::-1])
print "CRC32(%s) = 0x%08x" % (repr(arg), crc)
print ("CRC32(%s) = 0x%08x" % (repr(arg), crc))
assert(struct.pack('<L', crc) == check[::-1])
rcrc = CRC32().rcalc(arg[::-1], crc)
print "RCRC32(%s, 0x%08x) = 0x%08x" % (repr(arg), crc, rcrc)
print ("RCRC32(%s, 0x%08x) = 0x%08x" % (repr(arg), crc, rcrc))
assert(rcrc == 0xffffffff)

View File

@@ -301,18 +301,18 @@ class ELFObject:
if __name__ == '__main__':
print "This is only a module test!"
print ("This is only a module test!")
elf = ELFObject()
elf.fromFile(open("test.elf"))
if elf.e_type != ELFObject.ET_EXEC:
raise Exception("No executable")
print elf
print (elf)
#~ print repr(elf.getSection('.text').data)
#~ print [(s.name, hex(s.sh_addr)) for s in elf.getSections()]
print "-"*20
for p in elf.sections: print p
print "-"*20
for p in elf.getSections(): print p
print "-"*20
for p in elf.getProgrammableSections(): print p
print ("-"*20)
for p in elf.sections: print (p)
print ("-"*20)
for p in elf.getSections(): print (p)
print ("-"*20)
for p in elf.getProgrammableSections(): print (p)