(self, stream, result)
Reads all the stderr output from GPG, taking notice only of lines
        that begin with the magic [GNUPG:] prefix.

        Calls methods on the response object for each valid token found, with
        the arg being the remainder of the status line.

        :param stream: A byte-stream, file handle, or a
                       :data:`subprocess.PIPE` for parsing the status codes
                       from the GnuPG process.

        :param result: The result parser class from :mod:`~gnupg._parsers` ―
                       the ``handle_status()`` method of that class will be
                       called in order to parse the output of ``stream``.
Reads all the stderr output from GPG, taking notice only of lines
        that begin with the magic [GNUPG:] prefix.
Reads all the stderr output from GPG taking notice only of lines that begin with the magic [ GNUPG : ] prefix .
def _read_response(self, stream, result):
        """Reads all the stderr output from GPG, taking notice only of lines
        that begin with the magic [GNUPG:] prefix.

        Calls methods on the response object for each valid token found, with
        the arg being the remainder of the status line.

        :param stream: A byte-stream, file handle, or a
                       :data:`subprocess.PIPE` for parsing the status codes
                       from the GnuPG process.

        :param result: The result parser class from :mod:`~gnupg._parsers` ―
                       the ``handle_status()`` method of that class will be
                       called in order to parse the output of ``stream``.
        """
        # All of the userland messages (i.e. not status-fd lines) we're not
        # interested in passing to our logger
        userland_messages_to_ignore = []

        if self.ignore_homedir_permissions:
            userland_messages_to_ignore.append('unsafe ownership on homedir')

        lines = []

        while True:
            line = stream.readline()
            if len(line) == 0:
                break
            lines.append(line)
            line = line.rstrip()

            if line.startswith('[GNUPG:]'):
                line = _util._deprefix(line, '[GNUPG:] ', log.status)
                keyword, value = _util._separate_keyword(line)
                result._handle_status(keyword, value)
            elif line.startswith('gpg:'):
                line = _util._deprefix(line, 'gpg: ')
                keyword, value = _util._separate_keyword(line)

                # Silence warnings from gpg we're supposed to ignore
                ignore = any(msg in value for msg in userland_messages_to_ignore)

                if not ignore:
                    # Log gpg's userland messages at our own levels:
                    if keyword.upper().startswith("WARNING"):
                        log.warn("%s" % value)
                    elif keyword.upper().startswith("FATAL"):
                        log.critical("%s" % value)
                        # Handle the gpg2 error where a missing trustdb.gpg is,
                        # for some stupid reason, considered fatal:
                        if value.find("trustdb.gpg") and value.find("No such file"):
                            result._handle_status('NEED_TRUSTDB', '')
            else:
                if self.verbose:
                    log.info("%s" % line)
                else:
                    log.debug("%s" % line)
        result.stderr = ''.join(lines)
def _read_response ( self , stream , result ) : # All of the userland messages (i.e. not status-fd lines) we're not # interested in passing to our logger userland_messages_to_ignore = [ ] if self . ignore_homedir_permissions : userland_messages_to_ignore . append ( 'unsafe ownership on homedir' ) lines = [ ] while True : line = stream . readline ( ) if len ( line ) == 0 : break lines . append ( line ) line = line . rstrip ( ) if line . startswith ( '[GNUPG:]' ) : line = _util . _deprefix ( line , '[GNUPG:] ' , log . status ) keyword , value = _util . _separate_keyword ( line ) result . _handle_status ( keyword , value ) elif line . startswith ( 'gpg:' ) : line = _util . _deprefix ( line , 'gpg: ' ) keyword , value = _util . _separate_keyword ( line ) # Silence warnings from gpg we're supposed to ignore ignore = any ( msg in value for msg in userland_messages_to_ignore ) if not ignore : # Log gpg's userland messages at our own levels: if keyword . upper ( ) . startswith ( "WARNING" ) : log . warn ( "%s" % value ) elif keyword . upper ( ) . startswith ( "FATAL" ) : log . critical ( "%s" % value ) # Handle the gpg2 error where a missing trustdb.gpg is, # for some stupid reason, considered fatal: if value . find ( "trustdb.gpg" ) and value . find ( "No such file" ) : result . _handle_status ( 'NEED_TRUSTDB' , '' ) else : if self . verbose : log . info ( "%s" % line ) else : log . debug ( "%s" % line ) result . stderr = '' . join ( lines )