Commit 2cf522c3 authored by David Brown's avatar David Brown Committed by David Brown
Browse files

scripts: assemble: Fix problem with missing output

Adding an os.unlink() call to remove the outfile results in an exception
being thrown if the file does not exist.  Fix this by trapping, and
checking for the specific error we get on a missing file.

Signed-off-by: default avatarDavid Brown <david.brown@linaro.org>
parent dbc57279
Loading
Loading
Loading
Loading
+5
Changes for scripts/assemble.py: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ Assemble multiple images into a single image that can be flashed on the device.
"""

import argparse
import errno
import io
import re
import os.path
@@ -25,7 +26,11 @@ size_re = re.compile(r"^#define FLASH_AREA_([0-9A-Z_]+)_SIZE_0\s+((0x)?[0-9a-f
class Assembly():
    def __init__(self, output, bootdir):
        self.find_slots(bootdir)
        try:
            os.unlink(output)
        except OSError as e:
            if e.errno != errno.ENOENT:
                raise
        self.output = output

    def find_slots(self, bootdir):