@@ -17,21 +17,27 @@ def get_or_create_empty_image(index, tem
if rval != 0:
raise Exception('Not created')
return filename
def format_images(device, indexes, temp_path, size=1440):
def format_images(device, indexes, temp_path, size=1440, callback=None):
for ipair in indexes:
if isinstance(ipair, int):
image = get_or_create_empty_image(ipair, temp_path, size)
write_image(device, image, ipair)
os.remove(image)
if callback:
callback(indexes, ipair)
else:
for i in range(ipair[0], ipair[1]):
image = get_or_create_empty_image(i, temp_path, size)
write_image(device, image, i)
callback(ipair, i)
def write_image(device, path, index=0):
"""
Writes image from path to device at specified index
:param device: