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> <li>
<span class="leftTitle">内存占用</span> <span class="leftTitle">内存占用</span>
<div class="rightPercent"> <div class="rightPercent">
<span>{{platform_info.mem_total}}</span> <span>{{platform_info.mem_total|to_g}}</span>
<p style="width:{% present platform_info.mem_used platform_info.mem_total %}%">{{platform_info.mem_used}}</p > <p style="width:{% present platform_info.mem_used platform_info.mem_total %}%">{{platform_info.mem_used|to_g}}</p >
</div> </div>
</li> </li>
<li> <li>

View File

@ -7,3 +7,9 @@ register = template.Library()
def present(val1, val2): def present(val1, val2):
"""获取两个数的百分比,取整 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)