mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-22 07:44:03 -04:00
AP_OSD: Simplify with the code enumerate()
* Avoid hardcoding the path to the python executable on the shebang line * Using __with open() as__ automates file close().
This commit is contained in:
parent
a7042e3847
commit
7291aa0d00
@ -1,21 +1,17 @@
|
||||
#!/usr/bin/python
|
||||
import sys;
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
print "Usage: ./mcm2bin.py clarity.mcm clarity.bin"
|
||||
print("Usage: ./mcm2bin.py clarity.mcm clarity.bin")
|
||||
exit()
|
||||
|
||||
with open(sys.argv[1]) as inp:
|
||||
content = inp.readlines()
|
||||
inp.close();
|
||||
|
||||
content.pop(0)
|
||||
|
||||
out = open(sys.argv[2], 'wb')
|
||||
i = -1
|
||||
for line in content:
|
||||
i = i + 1
|
||||
if i % 64 < 54:
|
||||
b = int(line, 2)
|
||||
out.write(bytearray([b]))
|
||||
out.close()
|
||||
with open(sys.argv[2], 'wb') as out:
|
||||
for i, line in enumerate(content):
|
||||
if i % 64 < 54:
|
||||
b = int(line, 2)
|
||||
out.write(bytearray([b]))
|
||||
|
Loading…
Reference in New Issue
Block a user