diff options
author | Dan McGee <dan@archlinux.org> | 2009-10-13 19:38:42 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2009-10-13 19:38:42 -0500 |
commit | bcda0ab66b9722ae15c10645aa44bb1099d79a93 (patch) | |
tree | 99dea0632cf194acffc4a6a4dadbc7fbcae480a3 | |
parent | 7a2ae6b375410af1c34f65381b48ad5af21eb74d (diff) |
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 <dan@archlinux.org>
-rwxr-xr-x | scripts/reporead.py | 7 |
1 files changed, 6 insertions, 1 deletions
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) |