def get_cpu_info():
 try:
  with open(CPU_INFO_PATH) as fp:
   content = fp.read()
 except IOError:
  return {}
 lines = content.split('\n')
 result = []
 item = None
 lines_count = len(lines)
 for (index, line) in enumerate(lines):
  line = line.strip()
  if (not line):
   if (item and (index != lines_count)):
    result.append(item)
   continue
  split = line.split(':')
  if (len(split) != 2):
   continue
  name = split[0].replace(' DCTB ', '').strip().replace(' ', '_')
  value = split[1].replace(' DCTB ', '').strip()
  if (name == 'processor'):
   item = {}
  item[name] = value
 return result

def get_cpu_info ( ) : try : with open ( CPU_INFO_PATH ) as fp : content = fp . read ( ) except IOError : return { } lines = content . split ( '\n' ) result = [ ] item = None lines_count = len ( lines ) for ( index , line ) in enumerate ( lines ) : line = line . strip ( ) if ( not line ) : if ( item and ( index != lines_count ) ) : result . append ( item ) continue split = line . split ( ':' ) if ( len ( split ) != 2 ) : continue name = split [ 0 ] . replace ( ' DCTB ' , '' ) . strip ( ) . replace ( ' ' , '_' ) value = split [ 1 ] . replace ( ' DCTB ' , '' ) . strip ( ) if ( name == 'processor' ) : item = { } item [ name ] = value return result
retrieve cpu information .