<s> import os <EOL> def statvfs ( ) : <EOL> docker_path = '<STR_LIT>' <EOL> if not os . path . exists ( docker_path ) : <EOL> docker_path = '<STR_LIT:/>' <EOL> return os . statvfs ( docker_path ) <EOL> def get_meminfo ( ) : <EOL> with open ( '<STR_LIT>' ) as f : <EOL> return f . readlines ( ) <EOL> def get_disk_usage ( ) : <EOL> st = statvfs ( ) <EOL> return { <EOL> '<STR_LIT>' : st . f_blocks * st . f_frsize , <EOL> '<STR_LIT>' : st . f_bavail * st . f_frsize , <EOL> '<STR_LIT>' : ( st . f_blocks - st . f_bfree ) * st . f_frsize <EOL> } <EOL> def parse_meminfo ( ) : <EOL> meminfo = { } <EOL> for ln in get_meminfo ( ) : <EOL> parts = ln . split ( '<STR_LIT::>' ) <EOL> if len ( parts ) < <NUM_LIT:2> : <EOL> continue <EOL> key = parts [ <NUM_LIT:0> ] . lower ( ) <EOL> value = parts [ <NUM_LIT:1> ] . strip ( ) <EOL> parts = value . split ( '<STR_LIT:U+0020>' ) <EOL> value = parts [ <NUM_LIT:0> ] <EOL> if not value . isdigit ( ) : <EOL> continue <EOL> value = int ( parts [ <NUM_LIT:0> ] ) <EOL> if len ( parts ) > <NUM_LIT:1> and parts [ <NUM_LIT:1> ] == '<STR_LIT>' : <EOL> value *= <NUM_LIT> <EOL> meminfo [ key ] = value <EOL> return meminfo <EOL> def get_memory_usage ( ) : <EOL> meminfo = parse_meminfo ( ) <EOL> total = meminfo . get ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> free = meminfo . get ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> free += meminfo . get ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> free += meminfo . get ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> return { <EOL> '<STR_LIT>' : total , <EOL> '<STR_LIT>' : free , <EOL> '<STR_LIT>' : total - free <EOL> } </s>
