Runs a command and returns the exit code.
        The command can either be supplied as a sequence or string.

        An Exception is raised if an error occurs
332793
def command_run(self, command):
        
        # convert the command to sequence if a string
        if isinstance(command, basestring):
            command = shlex.split(command)
        try:
            return Popen(command, stdout=PIPE, stderr=PIPE, close_fds=True).wait()
        except Exception as e:
            # make a pretty command for error loggings and...
            if isinstance(command, basestring):
                pretty_cmd = command
            else:
                pretty_cmd = " ".join(command)
            msg = "Command `{cmd}` {error}".format(cmd=pretty_cmd, error=e.errno)
            raise exceptions.CommandError(msg, error_code=e.errno)
148542
def _run(self, command: List[str], notebook: Optional[str] = None) -> int:
        """"""
        if notebook is None:
            return Popen(command, cwd=self._build_dir).wait()
        cmd = Popen(command, cwd=self._build_dir, stdout=PIPE, stderr=STDOUT)
        while True:
            line = cmd.stdout.readline()
            if line == b'' and cmd.poll() is not None:
                return cmd.poll()
            print(line.decode('utf-8'), end='')
        raise Exception()
476469
def getExitCode(self, command, env={}, path=None, uid=None, gid=None,
                    usePTY=0, childFDs=None):
        
        deferred = defer.Deferred()
        processProtocol = _SummaryProcessProtocol(deferred)
        self.execute(processProtocol, command, env, path, uid, gid,
                     usePTY, childFDs)
        @deferred.addCallback
        def getStdOut(tuple_):
            _stdout, _stderr, exitCode = tuple_
            return exitCode
        return deferred
844948
def run(args: List[str],
        get_output: bool = False,
        encoding: str = sys.getdefaultencoding()) -> Tuple[str, str]:
    
    printable = " ".join(shlex.quote(x) for x in args).replace("\n", r"\n")
    log.debug("Running external command: {}", printable)
    if get_output:
        p = subprocess.run(args, stdout=subprocess.PIPE,
                           stderr=subprocess.PIPE, check=True)
        stdout, stderr = p.stdout.decode(encoding), p.stderr.decode(encoding)
    else:
        subprocess.check_call(args)
        stdout, stderr = "", ""
    return stdout, stderr
297089
def execd_run(command, execd_dir=None, die_on_error=True, stderr=subprocess.STDOUT):
    """"""
    for submodule_path in execd_submodule_paths(command, execd_dir):
        try:
            subprocess.check_output(submodule_path, stderr=stderr,
                                    universal_newlines=True)
        except subprocess.CalledProcessError as e:
            hookenv.log("Error ({}) running  {}. Output: {}".format(
                e.returncode, e.cmd, e.output))
            if die_on_error:
                sys.exit(e.returncode)
191917
def command(function):
    """"""
    def decorate(*args, **kwargs):
        exit_code = 1
        try:
            exit_code = function(*args, **kwargs)
        except Exception as e:
            if str(e):
                click.secho('Error: ' + str(e), fg='red')
        finally:
            return exit_code
    return decorate
364715
def call(cmd, input=None, assert_zero_exit_status=True, warn_on_non_zero_exist_status=False, **kwargs):
    
    if (not kwargs.get('shell')) and isinstance(cmd, basestring):
        raise ValueError('cmd should be list or tuple, not a string: %r' % cmd)
    result = SubprocessResult.call(cmd, input=input, **kwargs)
    if assert_zero_exit_status and result.ret != 0:
        raise SubprocessError(result)

    if warn_on_non_zero_exist_status and result.ret != 0:
        logger.warn('subprocess failed %r' % result)

    return result
592571
def run(command, **kwargs):
  
  print command
  p = Popen(shlex.split(command), **kwargs)
  p.wait()

  return p.returncode
1032147
def runCommands(self,commands,args):
        
        errorCounter = 0
        if args.list:
            print '\n'.join(commands)
        else:
            # Each command is executed sequentially:
            for command in commands:
                process = subprocess.Popen(command, stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
                stream = process.communicate()
                output = stream[0]
                erroroutput = stream[1]
                returncode = process.returncode
                if args.verbose:
                    print 'Executing command: '+command
                if returncode != 0:
                    errorCounter = errorCounter + 1
                    if args.verbose or not args.ignore_errors:
                        print 'An error occurred:\n'
                        print erroroutput
                    if not args.ignore_errors:
                        print('Terminating map process.')
                        break
                if returncode == 0 and len(output) > 0:
                    sys.stdout.write(output)
        if args.verbose:
            print 'Process completed successfully.'
            if errorCounter > 0:
                if errorCounter > 1:
                    print str(errorCounter) + ' errors occurred during the process.'
                else:
                    print str(errorCounter) + ' error occurred during the process.'
95428
def run(command):
    '''
    
    '''
    if isinstance(command, list):
        command = ' '.join(command)
    out = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    return (out.returncode, _prepare(out.stdout), _prepare(out.stderr))
85144
protected static String runCommand(String... command) {
		try {
			final Process p = Runtime.getRuntime().exec(command);
			if (p == null) {
				return null;
			}
			final StringBuilder bStr = new StringBuilder();
			try (InputStream standardOutput = p.getInputStream()) {
				final byte[] buffer = new byte[BUFFER_SIZE];
				int len;
				while ((len = standardOutput.read(buffer)) > 0) {
					bStr.append(new String(buffer, 0, len));
				}
				p.waitFor();
				return bStr.toString();
			}
		} catch (Exception e) {
			return null;
		}
	}
976349
def __exitfunction(self):
        '''
        
        '''
        if self._hook.exit_code is None and self._hook.exception is None:
            print("Check did not exit! You should call an exit code method.")
            sys.stdout.flush()
            os._exit(1)
        elif self._hook.exception:
            print("Check failed to run: %s, %s" %
                  (sys.last_type, traceback.format_tb(sys.last_traceback)))
            sys.stdout.flush()
            os._exit(2)
891629
def run(self, command):
        
        boto.log.debug('running:%s on %s' % (command, self.server.instance_id))
        status = 0
        try:
            t = self._ssh_client.exec_command(command)
        except paramiko.SSHException:
            status = 1
        std_out = t[1].read()
        std_err = t[2].read()
        t[0].close()
        t[1].close()
        t[2].close()
        boto.log.debug('stdout: %s' % std_out)
        boto.log.debug('stderr: %s' % std_err)
        return (status, std_out, std_err)
621160
def execute_command(self, cmd):
        
        if self.input_mode:
            self.end_input(cmd)
            return
        if cmd.endswith('\n'):
            cmd = cmd[:-1]
        # cls command
        if cmd == 'cls':
            self.clear_terminal()
            return
        self.run_command(cmd)
1049427
def run(command):
    
    p = Popen(command.split(), stdout=PIPE, stderr=PIPE)
    (stdout, stderr) = p.communicate()
    return (p.returncode, [line.strip() for line in stdout.splitlines()],
            [line.strip() for line in stderr.splitlines()])
1484
def run(command, encoding=None, decode=True, cwd=None):
    
    if not encoding:
        encoding = locale.getpreferredencoding()
    try:
        with open(os.devnull, 'rb') as devnull:
            pipe = subprocess.Popen(command, stdin=devnull,
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.STDOUT, cwd=cwd)
    except OSError as e:
        raise Failure("could not run %s: %s" % (command, e))
    output = pipe.communicate()[0]
    if decode:
        output = output.decode(encoding)
    status = pipe.wait()
    if status != 0:
        raise CommandFailed(command, status, output)
    return output
217445
def execute(cmd, cwd=None):
    
    try:
        lines = subprocess \
            .check_output(cmd, cwd=cwd, stderr=DEVNULL) \
            .splitlines()
    except subprocess.CalledProcessError:
        return None
    else:
        if lines:
            return decode(lines[0].strip())
        else:
            return None