From bcda0ab66b9722ae15c10645aa44bb1099d79a93 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 13 Oct 2009 19:38:42 -0500 Subject: reporead: don't blow up on division by zero We didn't sanity check the length of the DB set, so if it was zero we would blow up. Add a sanity check and also limit the whole thing to only apply if there are > 20 packages in a given {repo, arch} combo. Signed-off-by: Dan McGee --- scripts/reporead.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/reporead.py b/scripts/reporead.py index 9ff66c58..5d0ff262 100755 --- a/scripts/reporead.py +++ b/scripts/reporead.py @@ -219,7 +219,12 @@ def db_update(archname, pkgs): logger.info("%d packages in sync not db" % len(in_sync_not_db)) # Try to catch those random orphaning issues that make Eric so unhappy. - dbpercent = 100.0 * len(syncset) / len(dbset) + if len(dbset) > 20: + dbpercent = 100.0 * len(syncset) / len(dbset) + else: + # we don't have 20 packages in this repo/arch, so this check could + # produce a lot of false positives (or a div by zero). fake it + dbpercent = 100.0 logger.info("DB package ratio: %.1f%%" % dbpercent) if dbpercent < 50.0 and repository.name.lower().find('testing') == -1: logger.error(".db.tar.gz has %.1f%% the number of packages in the web database" % dbpercent) -- cgit v1.2.3-54-g00ecf