mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-29 06:06:32 +00:00
support/scripts/size-stats: avoid divide-by-zero
Some packages (ex: skeleton-init-systemd) have a zero size so we cannot divide by the package size. In that case make their percent zero explicitly and avoid a ZeroDivisionError exception. Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com> Acked-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
parent
86ad37b948
commit
88af7d330d
@ -178,9 +178,17 @@ def gen_files_csv(filesdict, pkgsizes, outputf):
|
|||||||
"File size in system (%)"])
|
"File size in system (%)"])
|
||||||
for f, (pkgname, filesize) in filesdict.items():
|
for f, (pkgname, filesize) in filesdict.items():
|
||||||
pkgsize = pkgsizes[pkgname]
|
pkgsize = pkgsizes[pkgname]
|
||||||
|
|
||||||
|
if pkgsize == 0:
|
||||||
|
percent_pkg = 0
|
||||||
|
else:
|
||||||
|
percent_pkg = float(filesize) / pkgsize * 100
|
||||||
|
|
||||||
|
percent_total = float(filesize) / total * 100
|
||||||
|
|
||||||
wr.writerow([f, pkgname, filesize, pkgsize,
|
wr.writerow([f, pkgname, filesize, pkgsize,
|
||||||
"%.1f" % (float(filesize) / pkgsize * 100),
|
"%.1f" % percent_pkg,
|
||||||
"%.1f" % (float(filesize) / total * 100)])
|
"%.1f" % percent_total])
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user