From eefd0cb8dd4a1bb73e700e971987e78090883efd Mon Sep 17 00:00:00 2001 From: pix106 Date: Fri, 13 Aug 2021 08:20:08 +0200 Subject: [PATCH] clover: update-sha1sums: handle FileNotFound exception Show missing file name and continue Signed-off-by: pix106 --- update-sha1sums.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/update-sha1sums.py b/update-sha1sums.py index 2c482ff..a7f7df1 100755 --- a/update-sha1sums.py +++ b/update-sha1sums.py @@ -104,10 +104,14 @@ def update(): if filePath[0] == '-': filePath = filePath[1:] - with open(os.path.join(vendorPath, filePath), 'rb') as f: - hash = sha1(f.read()).hexdigest() + try: + with open(os.path.join(vendorPath, filePath), 'rb') as f: + hash = sha1(f.read()).hexdigest() + lines[index] = '%s|%s' % (line, hash) + + except FileNotFoundError: + print("File not found: %s" % filePath) - lines[index] = '%s|%s' % (line, hash) lines.append('')