def psutil_wrapper(self, process, method, accessors, *args, **kwargs):
        """
        A psutil wrapper that is calling
        * psutil.method(*args, **kwargs) and returns the result
        OR
        * psutil.method(*args, **kwargs).accessor[i] for each accessors given in
        a list, the result being indexed in a dictionary by the accessor name
        """

        if accessors is None:
            result = None
        else:
            result = {}

        # Ban certain method that we know fail
        if method == 'memory_info_ex'\
                and (Platform.is_win32() or Platform.is_solaris()):
            return result
        elif method == 'num_fds' and not Platform.is_unix():
            return result

        try:
            res = getattr(process, method)(*args, **kwargs)
            if accessors is None:
                result = res
            else:
                for acc in accessors:
                    try:
                        result[acc] = getattr(res, acc)
                    except AttributeError:
                        self.log.debug("psutil.%s().%s attribute does not exist", method, acc)
        except (NotImplementedError, __HOLE__):
            self.log.debug("psutil method %s not implemented", method)
        except psutil.AccessDenied:
            self.log.debug("psutil was denied acccess for method %s", method)
        except psutil.NoSuchProcess:
            self.warning("Process {0} disappeared while scanning".format(process.pid))

        return result
dataset/ETHPy150Open serverdensity/sd-agent/checks.d/process.py/ProcessCheck.psutil_wrapper