diff --git a/chapter2/mysite/myapp/utils.py b/chapter2/mysite/myapp/utils.py index 01a6e7a..0598468 100644 --- a/chapter2/mysite/myapp/utils.py +++ b/chapter2/mysite/myapp/utils.py @@ -39,11 +39,11 @@ def get_platform_info(): #硬盘使用 out = get_execute_out('df -h') - m = re.match(r'\/dev\/vda1\s+?(.+?)G\s+(.+?)G\s+(.+?)G', out) - if m: - info['disk_total'] = m.group(1) - info['disk_used'] = m.group(2) - info['disk_freed'] = m.group(3) + m = re.findall(r'\/dev\/vda1\s+(.+?)G\s+(.+?)G\s+(.+?)G', out) + if len(m)>0: + info['disk_total'] = m[0][0] + info['disk_used'] = m[0][1] + info['disk_freed'] = m[0][2] return info