system-info: fix possible float division by zero in calculating % value

This commit is contained in:
Marcin Kuzminski 2016-11-04 12:07:18 +01:00
parent 70a6bbf0ff
commit a218d75e0a

View file

@ -892,7 +892,10 @@ class ScmModel(BaseModel):
from rhodecode.model.gist import GIST_STORE_LOC
def percentage(part, whole):
return 100 * float(part) / float(whole)
whole = float(whole)
if whole > 0:
return 100 * float(part) / whole
return 0
try:
# cygwin cannot have yet psutil support.