Skip to content

Commit b647353

Browse files
committed
python scripts changed to work with python 3
1 parent 0063bd8 commit b647353

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

pi/a_star.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def read_unpack(self, address, size, format):
2626
return struct.unpack(format,bytes(bytearray(byte_list)))
2727

2828
def write_pack(self, address, format, *data):
29-
data_array = map(ord, list(struct.pack(format, *data)))
29+
data_array = list(struct.pack(format, *data))
3030
self.bus.write_i2c_block_data(20, address, data_array)
3131
time.sleep(0.0001)
3232

pi/benchmark.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
total_time = timeit.timeit(a_star.test_write8, number=n)
1313
write_kbits_per_second = 8 * n * 8 / total_time / 1000
1414

15-
print "Writes of 8 bytes: "+'%.1f'%write_kbits_per_second+" kilobits/second"
15+
print("Writes of 8 bytes: "+'%.1f'%write_kbits_per_second+" kilobits/second")
1616

1717
n = 500
1818
total_time = timeit.timeit(a_star.test_read8, number=n)
1919
read_kbits_per_second = 8 * n * 8 / total_time / 1000
2020

21-
print "Reads of 8 bytes: "+'%.1f'%read_kbits_per_second+" kilobits/second"
21+
print("Reads of 8 bytes: "+'%.1f'%read_kbits_per_second+" kilobits/second")

pi/heartbeat.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
# Copyright Pololu Corporation. For more information, see https://www.pololu.com/
44

5-
import urllib2
5+
import urllib.request
66
import time
77

88
while True:
99
try:
1010
time.sleep(1)
11-
urllib2.urlopen("http://localhost:5000/heartbeat/1").read()
11+
urllib.request.urlopen("http://localhost:5000/heartbeat/1").read()
1212
time.sleep(0.01)
13-
urllib2.urlopen("http://localhost:5000/heartbeat/0").read()
14-
except urllib2.URLError:
13+
urllib.request.urlopen("http://localhost:5000/heartbeat/0").read()
14+
except urllib.request.URLError:
1515
print("error")

0 commit comments

Comments
 (0)