def sh2(cmd):
 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
 out = p.communicate()[0]
 retcode = p.returncode
 if retcode:
  raise subprocess.CalledProcessError(retcode, cmd)
 else:
  return out.rstrip().decode('utf-8', 'ignore')

def sh2 ( cmd ) : p = subprocess . Popen ( cmd , stdout = subprocess . PIPE , shell = True ) out = p . communicate ( ) [ 0 ] retcode = p . returncode if retcode : raise subprocess . CalledProcessError ( retcode , cmd ) else : return out . rstrip ( ) . decode ( 'utf-8' , 'ignore' )
execute command in a subshell .