Skip to content

Commit

Permalink
Fix all the prints with 2to3, some need to be undo
Browse files Browse the repository at this point in the history
  • Loading branch information
rbiasini committed Sep 25, 2019
1 parent 5a7aeba commit dbc2480
Show file tree
Hide file tree
Showing 25 changed files with 138 additions and 138 deletions.
12 changes: 6 additions & 6 deletions crypto/getcertheader.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def to_c_uint32(x):

cname = fn.split("/")[-1].split(".")[0] + "_rsa_key"

print 'RSAPublicKey '+cname+' = {.len = 0x20,'
print ' .n0inv = %dU,' % n0inv
print ' .n = %s,' % to_c_uint32(rsa.n)
print ' .rr = %s,' % to_c_uint32(rr)
print ' .exponent = %d,' % rsa.e
print '};'
print('RSAPublicKey '+cname+' = {.len = 0x20,')
print(' .n0inv = %dU,' % n0inv)
print(' .n = %s,' % to_c_uint32(rsa.n))
print(' .rr = %s,' % to_c_uint32(rr))
print(' .exponent = %d,' % rsa.e)
print('};')


4 changes: 2 additions & 2 deletions crypto/sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
with open(sys.argv[1]) as f:
dat = f.read()

print "signing", len(dat), "bytes"
print("signing", len(dat), "bytes")

with open(sys.argv[2], "wb") as f:
if os.getenv("SETLEN") is not None:
Expand All @@ -20,7 +20,7 @@
else:
x = dat
dd = hashlib.sha1(dat).digest()
print "hash:",dd.encode("hex")
print("hash:",dd.encode("hex"))
dd = "\x00\x01" + "\xff"*0x69 + "\x00" + dd
rsa_out = pow(int(dd.encode("hex"), 16), rsa.d, rsa.n)
sig = (hex(rsa_out)[2:-1].rjust(0x100, '0')).decode("hex")
Expand Down
8 changes: 4 additions & 4 deletions examples/can_bit_transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def printBitDiff(self, other):
for i in range(len(self.ones)):
zero_to_one = other.zeros[i] & self.ones[i]
if zero_to_one:
print 'id %s 0 -> 1 at byte %d bitmask %d' % (self.message_id, i, zero_to_one)
print('id %s 0 -> 1 at byte %d bitmask %d' % (self.message_id, i, zero_to_one))
one_to_zero = other.ones[i] & self.zeros[i]
if one_to_zero:
print 'id %s 1 -> 0 at byte %d bitmask %d' % (self.message_id, i, one_to_zero)
print('id %s 1 -> 0 at byte %d bitmask %d' % (self.message_id, i, one_to_zero))


class Info():
Expand Down Expand Up @@ -78,10 +78,10 @@ def PrintUnique(log_file, low_range, high_range):
if message_id in low.messages:
high.messages[message_id].printBitDiff(low.messages[message_id])
found = True
if not found: print 'No messages that transition from always low to always high found!'
if not found: print('No messages that transition from always low to always high found!')

if __name__ == "__main__":
if len(sys.argv) < 4:
print 'Usage:\n%s log.csv <low-start>-<low-end> <high-start>-<high-end>' % sys.argv[0]
print('Usage:\n%s log.csv <low-start>-<low-end> <high-start>-<high-end>' % sys.argv[0])
sys.exit(0)
PrintUnique(sys.argv[1], sys.argv[2], sys.argv[3])
12 changes: 6 additions & 6 deletions examples/can_unique.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ def printBitDiff(self, other):
for i in range(len(self.ones)):
new_ones = ((~other.ones[i]) & 0xff) & self.ones[i]
if new_ones:
print 'id %s new one at byte %d bitmask %d' % (
self.message_id, i, new_ones)
print('id %s new one at byte %d bitmask %d' % (
self.message_id, i, new_ones))
new_zeros = ((~other.zeros[i]) & 0xff) & self.zeros[i]
if new_zeros:
print 'id %s new zero at byte %d bitmask %d' % (
self.message_id, i, new_zeros)
print('id %s new zero at byte %d bitmask %d' % (
self.message_id, i, new_zeros))


class Info():
Expand Down Expand Up @@ -80,14 +80,14 @@ def PrintUnique(interesting_file, background_files):
interesting.load(interesting_file)
for message_id in sorted(interesting.messages):
if message_id not in background.messages:
print 'New message_id: %s' % message_id
print('New message_id: %s' % message_id)
else:
interesting.messages[message_id].printBitDiff(
background.messages[message_id])


if __name__ == "__main__":
if len(sys.argv) < 3:
print 'Usage:\n%s interesting.csv background*.csv' % sys.argv[0]
print('Usage:\n%s interesting.csv background*.csv' % sys.argv[0])
sys.exit(0)
PrintUnique(sys.argv[1], sys.argv[2:])
4 changes: 2 additions & 2 deletions examples/get_panda_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def get_panda_password():

wifi = p.get_serial()
#print('[%s]' % ', '.join(map(str, wifi)))
print("SSID: " + wifi[0])
print("Password: " + wifi[1])
print(("SSID: " + wifi[0]))
print(("Password: " + wifi[1]))

if __name__ == "__main__":
get_panda_password()
8 changes: 4 additions & 4 deletions examples/query_vin_and_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ def get_supported_pids():
isotp_send(panda, "\x09\x02", 0x7df)
ret = isotp_recv(panda, 0x7e8)
hexdump(ret)
print "VIN: %s" % ret[2:]
print("VIN: %s" % ret[2:])

# 03 = get DTCS
isotp_send(panda, "\x03", 0x7e0)
dtcs = isotp_recv(panda, 0x7e8)
print "DTCs:", dtcs[2:].encode("hex")
print("DTCs:", dtcs[2:].encode("hex"))

supported_pids = get_supported_pids()
print "Supported PIDs:",supported_pids
print("Supported PIDs:",supported_pids)

while 1:
speed = struct.unpack(">B", get_current_data_for_pid(13)[2:])[0] # kph
rpm = struct.unpack(">H", get_current_data_for_pid(12)[2:])[0]/4.0 # revs
throttle = struct.unpack(">B", get_current_data_for_pid(17)[2:])[0]/255.0 * 100 # percent
temp = struct.unpack(">B", get_current_data_for_pid(5)[2:])[0] - 40 # degrees C
load = struct.unpack(">B", get_current_data_for_pid(4)[2:])[0]/255.0 * 100 # percent
print "%d KPH, %d RPM, %.1f%% Throttle, %d deg C, %.1f%% load" % (speed, rpm, throttle, temp, load)
print("%d KPH, %d RPM, %.1f%% Throttle, %d deg C, %.1f%% load" % (speed, rpm, throttle, temp, load))
time.sleep(0.2)


Expand Down
4 changes: 2 additions & 2 deletions examples/tesla_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def tesla_tester():
vin_index = int(binascii.hexlify(dat)[:2]) #first byte is the index, 00, 01, 02
vin_string = binascii.hexlify(dat)[2:] #rest of the string is the actual VIN data
vin[vin_index] = vin_string.decode("hex")
print("Got VIN index " + str(vin_index) + " data " + vin[vin_index])
print(("Got VIN index " + str(vin_index) + " data " + vin[vin_index]))
#if we have all 3 parts of the VIN, print it and break out of our while loop
if 0 in vin and 1 in vin and 2 in vin:
print("VIN: " + vin[0] + vin[1] + vin[2][:3])
print(("VIN: " + vin[0] + vin[1] + vin[2][:3]))
break

if __name__ == "__main__":
Expand Down
Loading

0 comments on commit dbc2480

Please sign in to comment.