def _marshal(self, newSerial=True, oobFDs=None):
        """
        Encodes the message into binary format. The resulting binary message is
        stored in C{self.rawMessage}
        """
        flags = 0

        if not self.expectReply:
            flags |= 0x1

        if not self.autoStart:
            flags |= 0x2

        # may be overriden below, depending on oobFDs
        _headerAttrs = self._headerAttrs

        # marshal body before headers to know if the 'unix_fd' header is needed
        if self.signature:
            binBody = b''.join(
                marshal.marshal(
                    self.signature,
                    self.body,
                    oobFDs=oobFDs
                )[1]
            )
            if oobFDs:
                # copy class based _headerAttrs to add a unix_fds header this
                # time
                _headerAttrs = list(self._headerAttrs)
                _headerAttrs.append(('unix_fds', 9, False))
                self.unix_fds = len(oobFDs)
        else:
            binBody = b''

        self.headers = []

        for attr_name, code, _ in _headerAttrs:
            hval = getattr(self, attr_name, None)

            if hval is not None:
                if attr_name == 'path':
                    hval = marshal.ObjectPath(hval)
                elif attr_name == 'signature':
                    hval = marshal.Signature(hval)
                elif attr_name == 'unix_fds':
                    hval = marshal.UInt32(hval)

                self.headers.append([code, hval])

        self.bodyLength = len(binBody)

        if newSerial:
            self.serial = DBusMessage._nextSerial

            DBusMessage._nextSerial += 1

        binHeader = b''.join(marshal.marshal(
            _headerFormat,
            [
                self.endian,
                self._messageType,
                flags,
                self._protocolVersion,
                self.bodyLength,
                self.serial,
                self.headers
            ],
            lendian=self.endian == ord('l')
        )[1])

        headerPadding = marshal.pad['header'](len(binHeader))

        self.rawHeader = binHeader
        self.rawPadding = headerPadding
        self.rawBody = binBody

        self.rawMessage = b''.join([binHeader, headerPadding, binBody])

        if len(self.rawMessage) > self._maxMsgLen:
            raise error.MarshallingError(
                'Marshalled message exceeds maximum message size of %d' %
                (self._maxMsgLen,),
            )
def _marshal ( self , newSerial = True , oobFDs = None ) : flags = 0 if not self . expectReply : flags |= 0x1 if not self . autoStart : flags |= 0x2 _headerAttrs = self . _headerAttrs if self . signature : binBody = b'' . join ( marshal . marshal ( self . signature , self . body , oobFDs = oobFDs ) [ 1 ] ) if oobFDs : _headerAttrs = list ( self . _headerAttrs ) _headerAttrs . append ( ( 'unix_fds' , 9 , False ) ) self . unix_fds = len ( oobFDs ) else : binBody = b'' self . headers = [ ] for attr_name , code , _ in _headerAttrs : hval = getattr ( self , attr_name , None ) if hval is not None : if attr_name == 'path' : hval = marshal . ObjectPath ( hval ) elif attr_name == 'signature' : hval = marshal . Signature ( hval ) elif attr_name == 'unix_fds' : hval = marshal . UInt32 ( hval ) self . headers . append ( [ code , hval ] ) self . bodyLength = len ( binBody ) if newSerial : self . serial = DBusMessage . _nextSerial DBusMessage . _nextSerial += 1 binHeader = b'' . join ( marshal . marshal ( _headerFormat , [ self . endian , self . _messageType , flags , self . _protocolVersion , self . bodyLength , self . serial , self . headers ] , lendian = self . endian == ord ( 'l' ) ) [ 1 ] ) headerPadding = marshal . pad [ 'header' ] ( len ( binHeader ) ) self . rawHeader = binHeader self . rawPadding = headerPadding self . rawBody = binBody self . rawMessage = b'' . join ( [ binHeader , headerPadding , binBody ] ) if len ( self . rawMessage ) > self . _maxMsgLen : raise error . MarshallingError ( 'Marshalled message exceeds maximum message size of %d' % ( self . _maxMsgLen , ) , )
Encodes the message into binary format. The resulting binary message is
        stored in C{self.rawMessage}