def get_memory_info():
 try:
  with open(MEMORY_INFO_PATH) as fp:
   content = fp.read()
 except IOError:
  return {}
 lines = content.split('\n')
 result = {}
 for line in lines:
  line = line.strip()
  if (not line):
   continue
  split = line.split(':')
  name = split[0].strip()
  value = split[1].replace('kB', '').strip()
  try:
   value = int(value)
  except Exception:
   continue
  result[name] = value
 return result

def get_memory_info ( ) : try : with open ( MEMORY_INFO_PATH ) as fp : content = fp . read ( ) except IOError : return { } lines = content . split ( '\n' ) result = { } for line in lines : line = line . strip ( ) if ( not line ) : continue split = line . split ( ':' ) name = split [ 0 ] . strip ( ) value = split [ 1 ] . replace ( 'kB' , '' ) . strip ( ) try : value = int ( value ) except Exception : continue result [ name ] = value return result
retrieve memory information .