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: David Brown <david.brown@linaro.org>
diff --git a/scripts/assemble.py b/scripts/assemble.py
index 92623c4..30adcba 100755
--- a/scripts/assemble.py
+++ b/scripts/assemble.py
@@ -5,6 +5,7 @@
"""
import argparse
+import errno
import io
import re
import os.path
@@ -25,7 +26,11 @@
class Assembly():
def __init__(self, output, bootdir):
self.find_slots(bootdir)
- os.unlink(output)
+ try:
+ os.unlink(output)
+ except OSError as e:
+ if e.errno != errno.ENOENT:
+ raise
self.output = output
def find_slots(self, bootdir):