def free_swap():
 out = sh('free -b')
 lines = out.split('\n')
 for line in lines:
  if line.startswith('Swap'):
   (_, total, used, free) = line.split()
   nt = collections.namedtuple('free', 'total used free')
   return nt(int(total), int(used), int(free))
 raise ValueError(("can't find 'Swap' in 'free' output:\n%s" % '\n'.join(lines)))

def free_swap ( ) : out = sh ( 'free -b' ) lines = out . split ( '\n' ) for line in lines : if line . startswith ( 'Swap' ) : ( _ , total , used , free ) = line . split ( ) nt = collections . namedtuple ( 'free' , 'total used free' ) return nt ( int ( total ) , int ( used ) , int ( free ) ) raise ValueError ( ( "can't find 'Swap' in 'free' output:\n%s" % '\n' . join ( lines ) ) )
parse free cmd and return swap memorys s total .