WebSocket to execute command
356557
function (command, id) {
        id = id || '';
        if (id) {
          this.queue.push(id);
        }
        SocketService.emit('execute', {
          command: command,
          id: id
        });
      }
730873
def _execute(self, command, stdin=None, stdout=subprocess.PIPE):
        
        process = subprocess.Popen(command, shell=True, cwd=self.root_path, stdin=stdin, stdout=stdout)
        return (process.wait(), None if stdout is not subprocess.PIPE else process.communicate()[0].decode('utf-8'))
1308452
def run_command(cmd):
    '''
    '''
    output = Popen(cmd,stderr=STDOUT,stdout=PIPE)
    t = output.communicate()[0],output.returncode
    output = {'message':t[0],
              'return_code':t[1]}

    return output
832325
def send_command(self, command: str, *args, **kwargs):
        
        info = 'send command `%s` to bot. Args: %s | Kwargs: %s'
        self._messaging_logger.command.info(info, command, args, kwargs)

        command = command.encode('utf8')
        # target = target.encode('ascii')
        args = _json.dumps(args).encode('utf8')
        kwargs = _json.dumps(kwargs).encode('utf8')
        frame = (b'', command, args, kwargs)
        debug = ' send command run_control_loop: %s'
        self._messaging_logger.command.debug(debug, self._run_control_loop)

        if self._run_control_loop:
            self.add_callback(self.command_socket.send_multipart, frame)
        else:
            self.command_socket.send_multipart(frame)
306600
function bridgeCommand(command,cb){
    if(!connected) return setImmediate(function(){
      cb('killed');
    });

    if(!connected.pings) connected.pings = {};
    var id = ++pingid;
    var timer;
    connected.pings[id] = function(err,data){
      clearTimeout(timer);
      delete connected.pings[id]
      cb(err,data);
    };
    connected.send({command:command,cb:id});
    // set 5 second time limit for callback.
    timer = setTimeout(function(){
      cb("timeout");
    },5000);
  }
716001
def execute(self, *args):
        """"""
        command, kwargs = self.parse(*args)
        return self._commands.execute(command, **kwargs)
359250
private String executeCommand(String command) {
        System.out.println("Execute: " + command);

        StringBuilder output = new StringBuilder();
        Process       p;
        try {
            p = Runtime.getRuntime().exec(command);
            p.waitFor();
            BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
            String         line;
            while ((line = reader.readLine()) != null) {
                output.append(line).append("\n");
            }
        } catch (Exception e) {
            throw new WebpIOException(e);
        }
        if (!"".equals(output.toString())) {
            System.out.println("Output: " + output);
        }
        return "";
    }
609381
def _run_command(self, packet):
        
        create_temp_cli = self.client_states is None

        if create_temp_cli:
            # If this client doesn't have a CLI. Create a Fake CLI where the
            # window containing this pane, is the active one. (The CLI instance
            # will be removed before the render function is called, so it doesn't
            # hurt too much and makes the code easier.)
            pane_id = int(packet['pane_id'])
            self._create_app()
            with set_app(self.client_state.app):
                self.pymux.arrangement.set_active_window_from_pane_id(pane_id)

        with set_app(self.client_state.app):
            try:
                self.pymux.handle_command(packet['data'])
            finally:
                self._close_connection()
270051
function controlChannelRequest(server, message) {
  var address = message.request.address;
  var req = { headers: {} };
  var headers = [];

  // handler to call when the connection sequence completes
  var self = server;
  
  if ( message.request.method) {
    req = new IncomingMessage(message, server.controlChannel);
    if ( message.request.body == true) {
       self.pendingRequest = req;
    } else {
      req.push(null);
    }
  }
  
  // execute the web socket rendezvous with the server
  try {
    var client = new WebSocket(address, {
      headers: headers,
      perMessageDeflate: false
    });
    client.on('open', function() {
      
      server.emit('requestchannel', client);
      if (self.options.clientTracking) {
        self.clients.push(client);
        ws.on('close', function() {
          var index = self.clients.indexOf(client);
          if (index != -1) {
            self.clients.splice(index, 1);
          }
        });
      }

      // do we have a request or is this just rendezvous?
      if ( message.request.method) {
         var res = new ServerResponse(req);
         res.requestId = message.request.id;
         res.assignSocket(client);
         server.emit('request', req, res);
      }
    });

    client.on('error', function(event) {
      var index = server.clients.indexOf(client);
      if (index != -1) {
        server.clients.splice(index, 1);
      }
    });

  } catch (err) {
    console.log(err);
  }
}
136842
def _execute_command(cmd, at_time=None):
    '''
    
    '''
    if at_time:
        cmd = 'echo \'{0}\' | at {1}'.format(cmd, _cmd_quote(at_time))
    return not bool(__salt__['cmd.retcode'](cmd, python_shell=True))
922133
def _command(self, sock_info, command, slave_ok=False, value=1, check=True,
                 allowable_errors=None, read_preference=ReadPreference.PRIMARY,
                 codec_options=DEFAULT_CODEC_OPTIONS,
                 write_concern=None,
                 parse_write_concern_error=False, session=None, **kwargs):
        """"""
        if isinstance(command, string_type):
            command = SON([(command, value)])

        command.update(kwargs)
        with self.__client._tmp_session(session) as s:
            return sock_info.command(
                self.__name,
                command,
                slave_ok,
                read_preference,
                codec_options,
                check,
                allowable_errors,
                write_concern=write_concern,
                parse_write_concern_error=parse_write_concern_error,
                session=s,
                client=self.__client)
963197
def execute_command(self, command, **kwargs):
        

        self.info_log("executing command: %s" % command)

        try:
            ssh = paramiko.SSHClient()
            ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

            username = kwargs.get(
                'username',
                self.browser_config.get('username')
            )
            password = self.browser_config.get('password')

            ssh.connect(self.get_ip(), username=username, password=password)

            stdin, stdout, stderr = ssh.exec_command(command)

            ssh.close()

            return (stdout, stderr)

        except Exception as e:
            msg = "Execute_command exception: %s" % str(e)
            self.error_log(msg)
            raise Exception(msg)
497174
function executeCommand(sid, command, ain, options, path)
{
    path = path || '/webservices/homeautoswitch.lua?0=0';

    if (sid)
        path += '&sid=' + sid;
    if (command)
        path += '&switchcmd=' + command;
    if (ain)
        path += '&ain=' + ain;

    return httpRequest(path, {}, options);
}
572263
def _handle_command(self, connection, sender, target, command, payload):
        
        try:
            # Find the handler
            handler = getattr(self, "cmd_{0}".format(command))
        except AttributeError:
            self.safe_send(connection, target, "Unknown command: %s",
                            command)
        else:
            try:
                logging.info("! Handling command: %s", command)
                handler(connection, sender, target, payload)
            except Exception as ex:
                logging.exception("Error calling command handler: %s", ex)
295461
async function Execute(command, args, watch) {
    let coverage = args.filter(s => s === "--cover").length > 0; 
    let full = args.filter(s => s === "--full").length > 0;
    switch (command) {
        case "wp":
            let wp = `webpack --config ./config/webpack.${args[0]}.ts`;
            if (watch) wp += " --watch";
            await run(wp);
            break;
        case "deploy":
            await run("node script unit --cover");
            await run("node script wp dist");
            break;
        case "unit":
            let mocha = `mocha --opts ./config/mocha.opts`;
            if (watch) mocha += " --watch-extensions ts --watch ";
            if (coverage) mocha = "nyc --nycrc-path ./config/.nycrc " + mocha; 
            if (fs.existsSync("./.nyc_output")) rimraf.sync("./.nyc_output"); 
            await run(mocha);
            break;
        case "publish":
            await run(`npm run deploy`);
            await run(`git add .`); 
            await run(`git commit -m "Preparing for next ${args[0]} version`); 
            await run(`npm version ${args[0]}`);
            await run(`npm publish`);
            break;
        default:
            console.log("Unknown command!");
            process.exit(1);
    }

}
27101
function WSMuxChannel(id, mux) {
  EventEmitter.call(this);
  this.id = id;
  this.mux = mux;
  this.closed = false;
  this.url = this.mux.url;

  // websocket-stream relies on this method
  this.__defineGetter__('readyState', function() {
    return this.mux._readyState();
  });

  // hooks for websocket-stream
  var _this = this;
  this.on('open', function() {
    _this.onopen && _this.onopen.apply(_this, arguments);
  });

  this.on('close', function() {
    _this.onclose && _this.onclose.apply(_this, arguments);
  });

  this.on('error', function() {
    _this.onerror && _this.onerror.apply(_this, arguments);
  });

  this.on('message', function() {
    arguments[0] = {data: arguments[0]}
    _this.onmessage && _this.onmessage.apply(_this, arguments);
  });
}
705762
def call(self, command, params=None, expect_body=True, stream=False):
        
        if self._socket is None:
            raise SerfConnectionError('handshake must be made first')

        header = msgpack.packb({"Seq": self._counter(), "Command": command})

        if params is not None:
            body = msgpack.packb(params)
            self._socket.sendall(header + body)
        else:
            self._socket.sendall(header)

        unpacker = msgpack.Unpacker(object_hook=self._decode_addr_key)

        def read_from_socket():
            try:
                buf = self._socket.recv(self._socket_recv_size)
                if len(buf) == 0:  # Connection was closed.
                    raise SerfConnectionError("Connection closed by peer")
                unpacker.feed(buf)
            except socket.timeout:
                raise SerfTimeout(
                    "timeout while waiting for an RPC response. (Have %s so"
                    "far)", response)

        if stream:
            def keep_reading_from_stream(init=[]):
                sub_response = SerfResult()
                while True:
                    if init is not None:
                        it = init
                        init = None
                    else:
                        if self._socket is None:
                            return
                        read_from_socket()
                        it = unpacker
                    for msg in it:
                        if sub_response.head is None:
                            sub_response.head = msg
                        elif sub_response.body is None:
                            sub_response.body = msg
                            yield sub_response
                            sub_response = SerfResult()
            mem = []
            messages_expected = 1
            while messages_expected > 0:
                read_from_socket()
                # Might have received enough to deserialise one or more
                # messages, try to fill out the response object.
                for message in unpacker:
                    mem.append(message)
                    messages_expected -= 1

            # Disable timeout while we are in streaming mode
            self._socket.settimeout(None)

            response = SerfResult()
            response.head = mem.pop()
            response.body = keep_reading_from_stream(mem)
        else:
            # The number of msgpack messages that are expected
            # in response to this command.
            messages_expected = 2 if expect_body else 1

            response = SerfResult()
            # Continue reading from the network until the expected number of
            # msgpack messages have been received.
            while messages_expected > 0:
                read_from_socket()
                # Might have received enough to deserialise one or more
                # messages, try to fill out the response object.
                for message in unpacker:
                    if response.head is None:
                        response.head = message
                    elif response.body is None:
                        response.body = message
                    else:
                        raise SerfProtocolError(
                            "protocol handler got more than 2 messages. "
                            "Unexpected message is: %s", message)

                    # Expecting one fewer message now.
                    messages_expected -= 1

        return response