(cls)
return False
Discover if a gpg-agent process for the current euid is running.

        If there is a matching gpg-agent process, set a :class:`psutil.Process`
        instance containing the gpg-agent process' information to
        ``cls._agent_proc``.

        For Unix systems, we check that the effective UID of this
        ``python-gnupg`` process is also the owner of the gpg-agent
        process. For Windows, we check that the usernames of the owners are
        the same. (Sorry Windows users; maybe you should switch to anything
        else.)

        .. note: This function will only run if the psutil_ Python extension
            is installed. Because psutil won't run with the PyPy interpreter,
            use of it is optional (although highly recommended).

        .. _psutil: https://pypi.python.org/pypi/psutil

        :returns: True if there exists a gpg-agent process running under the
                  same effective user ID as that of this program. Otherwise,
                  returns False.
Discover if a gpg-agent process for the current euid is running.
Discover if a gpg - agent process for the current euid is running .
def _find_agent(cls):
        """Discover if a gpg-agent process for the current euid is running.

        If there is a matching gpg-agent process, set a :class:`psutil.Process`
        instance containing the gpg-agent process' information to
        ``cls._agent_proc``.

        For Unix systems, we check that the effective UID of this
        ``python-gnupg`` process is also the owner of the gpg-agent
        process. For Windows, we check that the usernames of the owners are
        the same. (Sorry Windows users; maybe you should switch to anything
        else.)

        .. note: This function will only run if the psutil_ Python extension
            is installed. Because psutil won't run with the PyPy interpreter,
            use of it is optional (although highly recommended).

        .. _psutil: https://pypi.python.org/pypi/psutil

        :returns: True if there exists a gpg-agent process running under the
                  same effective user ID as that of this program. Otherwise,
                  returns False.
        """
        if not psutil:
            return False

        this_process = psutil.Process(os.getpid())
        ownership_match = False

        if _util._running_windows:
            identity = this_process.username()
        else:
            identity = this_process.uids

        for proc in psutil.process_iter():
            try:
                # In my system proc.name & proc.is_running are methods
                if (proc.name() == "gpg-agent") and proc.is_running():
                    log.debug("Found gpg-agent process with pid %d" % proc.pid)
                    if _util._running_windows:
                        if proc.username() == identity:
                            ownership_match = True
                    else:
                        # proc.uids & identity are methods to
                        if proc.uids() == identity():
                            ownership_match = True
            except psutil.Error as err:
                # Exception when getting proc info, possibly because the
                # process is zombie / process no longer exist. Just ignore it.
                log.warn("Error while attempting to find gpg-agent process: %s" % err)
            # Next code must be inside for operator.
            # Otherwise to _agent_proc will be saved not "gpg-agent" process buth an other.
            if ownership_match:
                log.debug("Effective UIDs of this process and gpg-agent match")
                setattr(cls, '_agent_proc', proc)
                return True

        return False
def _find_agent ( cls ) : if not psutil : return False this_process = psutil . Process ( os . getpid ( ) ) ownership_match = False if _util . _running_windows : identity = this_process . username ( ) else : identity = this_process . uids for proc in psutil . process_iter ( ) : try : # In my system proc.name & proc.is_running are methods if ( proc . name ( ) == "gpg-agent" ) and proc . is_running ( ) : log . debug ( "Found gpg-agent process with pid %d" % proc . pid ) if _util . _running_windows : if proc . username ( ) == identity : ownership_match = True else : # proc.uids & identity are methods to if proc . uids ( ) == identity ( ) : ownership_match = True except psutil . Error as err : # Exception when getting proc info, possibly because the # process is zombie / process no longer exist. Just ignore it. log . warn ( "Error while attempting to find gpg-agent process: %s" % err ) # Next code must be inside for operator. # Otherwise to _agent_proc will be saved not "gpg-agent" process buth an other. if ownership_match : log . debug ( "Effective UIDs of this process and gpg-agent match" ) setattr ( cls , '_agent_proc' , proc ) return True return False