Skip to contentSkip to conversation

cve-generate-chartdata: Handle unexpected files in the stats directory

PATCH New Richard Purdie 1 participant 1 message Apr 26, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cve-generate-chartdata: Handle unexpected files in the stats directory

A build of "stable/dunfell-nut" caused incorrect data to be added to the metrics repo and resulted in script failures. Handle this situation better.

---
 scripts/cve-generate-chartdata | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
scripts/cve-generate-chartdata +5 -1
index e187f8b..8b9df64 100755
@@ -28,7 +28,11 @@ for branch in os.listdir(args.resultsdir):
     branchdir = os.path.join(args.resultsdir, branch)
     for f in os.listdir(branchdir):
         ts = f.split(".")[0]
-        rounded_ts = str(round_to_day(ts))
+        try:
+            rounded_ts = str(round_to_day(ts))
+        except ValueError:
+            # Couldn't parse a timestamp from filename
+            continue
         if rounded_ts not in counts:
             counts[rounded_ts] = {}
         if branch not in counts[rounded_ts]:
Signature · 1 line
2.40.1