This commit is contained in:
guange 2019-01-21 11:09:57 +08:00
parent 36cd7233b1
commit 5256821b7e
2 changed files with 9 additions and 3 deletions

View File

@ -119,8 +119,8 @@
<li>
<span class="leftTitle">内存占用</span>
<div class="rightPercent">
<span>{{platform_info.mem_total}}</span>
<p style="width:{% present platform_info.mem_used platform_info.mem_total %}%">{{platform_info.mem_used}}</p >
<span>{{platform_info.mem_total|to_g}}</span>
<p style="width:{% present platform_info.mem_used platform_info.mem_total %}%">{{platform_info.mem_used|to_g}}</p >
</div>
</li>
<li>

View File

@ -6,4 +6,10 @@ register = template.Library()
@register.simple_tag
def present(val1, val2):
"""获取两个数的百分比,取整 val1 / val2 """
return int(int(val1) * 100 / int(val2))
return int(int(val1) * 100 / int(val2))
@register.filter
def to_g(val):
"""字节到G"""
return int(int(val)/1024/1024)