def runSubprocess(command, return_code=False, **kwargs):
 use_kwargs = dict(stderr=None, stdout=sp.PIPE)
 use_kwargs.update(kwargs)
 p = sp.Popen(command, **use_kwargs)
 output = p.communicate()[0]
 output = ('' if (output is None) else output)
 output = (output.decode('utf-8') if isinstance(output, bytes) else output)
 if (p.returncode != 0):
  print output
  err_fun = sp.CalledProcessError.__init__
  if ('output' in inspect.getargspec(err_fun).args):
   raise sp.CalledProcessError(p.returncode, command, output)
  else:
   raise sp.CalledProcessError(p.returncode, command)
 return output

def runSubprocess ( command , return_code = False , ** kwargs ) : use_kwargs = dict ( stderr = None , stdout = sp . PIPE ) use_kwargs . update ( kwargs ) p = sp . Popen ( command , ** use_kwargs ) output = p . communicate ( ) [ 0 ] output = ( '' if ( output is None ) else output ) output = ( output . decode ( 'utf-8' ) if isinstance ( output , bytes ) else output ) if ( p . returncode != 0 ) : print output err_fun = sp . CalledProcessError . __init__ if ( 'output' in inspect . getargspec ( err_fun ) . args ) : raise sp . CalledProcessError ( p . returncode , command , output ) else : raise sp . CalledProcessError ( p . returncode , command ) return output
run command using subprocess .