(self, stream='stdout stderr', command_id=None, timeout=None)
return command_state, rc, buffer
Send a receive message to the WSMan host

        :param stream: The stream(s) separated by a space to receive the
            response for
        :param command_id: If specified the COmmand ID to receive the response
            from the command and not the shell
        :param timeout: Override the default WSMan timeout on the receive
            command
        :return: A tuple of
            state: The command state on the received response
            rc: The return code (if any) on the received response
            buffer: A dict containing a byte string for each buffer, the stream
                name of each buffer is the key in this return value
Send a receive message to the WSMan host
Send a receive message to the WSMan host
def receive(self, stream='stdout stderr', command_id=None, timeout=None):
        """
        Send a receive message to the WSMan host

        :param stream: The stream(s) separated by a space to receive the
            response for
        :param command_id: If specified the COmmand ID to receive the response
            from the command and not the shell
        :param timeout: Override the default WSMan timeout on the receive
            command
        :return: A tuple of
            state: The command state on the received response
            rc: The return code (if any) on the received response
            buffer: A dict containing a byte string for each buffer, the stream
                name of each buffer is the key in this return value
        """
        rsp = NAMESPACES['rsp']

        receive = ET.Element("{%s}Receive" % rsp)
        stream_xml = ET.SubElement(receive,
                                   "{%s}DesiredStream" % rsp)
        stream_xml.text = stream
        if command_id is not None:
            stream_xml.attrib['CommandId'] = command_id

        options = OptionSet()
        options.add_option('WSMAN_CMDSHELL_OPTION_KEEPALIVE', True)

        response = self.wsman.receive(self.resource_uri, receive,
                                      option_set=options,
                                      selector_set=self._selector_set,
                                      timeout=timeout)

        command_state = response.find("rsp:ReceiveResponse/"
                                      "rsp:CommandState",
                                      namespaces=NAMESPACES)
        if command_state is not None:
            command_state = command_state.attrib['State']

        rc = response.find("rsp:ReceiveResponse/"
                           "rsp:CommandState/"
                           "rsp:ExitCode",
                           namespaces=NAMESPACES)
        if rc is not None:
            rc = int(rc.text)

        buffer = {}
        for stream_name in stream.split(" "):
            buffer[stream_name] = b""
        streams = response.findall("rsp:ReceiveResponse/"
                                   "rsp:Stream",
                                   namespaces=NAMESPACES)
        for stream in streams:
            if stream.text is None:
                continue

            stream_value = base64.b64decode(stream.text.encode('utf-8'))
            stream_name = stream.attrib['Name']
            buffer[stream_name] += stream_value

        return command_state, rc, buffer
def receive ( self , stream = 'stdout stderr' , command_id = None , timeout = None ) : rsp = NAMESPACES [ 'rsp' ] receive = ET . Element ( "{%s}Receive" % rsp ) stream_xml = ET . SubElement ( receive , "{%s}DesiredStream" % rsp ) stream_xml . text = stream if command_id is not None : stream_xml . attrib [ 'CommandId' ] = command_id options = OptionSet ( ) options . add_option ( 'WSMAN_CMDSHELL_OPTION_KEEPALIVE' , True ) response = self . wsman . receive ( self . resource_uri , receive , option_set = options , selector_set = self . _selector_set , timeout = timeout ) command_state = response . find ( "rsp:ReceiveResponse/" "rsp:CommandState" , namespaces = NAMESPACES ) if command_state is not None : command_state = command_state . attrib [ 'State' ] rc = response . find ( "rsp:ReceiveResponse/" "rsp:CommandState/" "rsp:ExitCode" , namespaces = NAMESPACES ) if rc is not None : rc = int ( rc . text ) buffer = { } for stream_name in stream . split ( " " ) : buffer [ stream_name ] = b"" streams = response . findall ( "rsp:ReceiveResponse/" "rsp:Stream" , namespaces = NAMESPACES ) for stream in streams : if stream . text is None : continue stream_value = base64 . b64decode ( stream . text . encode ( 'utf-8' ) ) stream_name = stream . attrib [ 'Name' ] buffer [ stream_name ] += stream_value return command_state , rc , buffer