@internationalizeDocstring
    def cpu(self, irc, msg, args):
        """takes no arguments

        Returns some interesting CPU-related statistics on the bot.
        """
        (user, system, childUser, childSystem, elapsed) = os.times()
        now = time.time()
        target = msg.args[0]
        timeRunning = now - world.startedAt
        if self.registryValue('cpu.children', target) and \
           user+system < timeRunning+1: # Fudge for FPU inaccuracies.
            children = _('My children have taken %.2f seconds of user time '
                       'and %.2f seconds of system time '
                       'for a total of %.2f seconds of CPU time.') % \
                       (childUser, childSystem, childUser+childSystem)
        else:
            children = ''
        activeThreads = threading.activeCount()
        response = _('I have taken %.2f seconds of user time and %.2f seconds '
                   'of system time, for a total of %.2f seconds of CPU '
                   'time.  %s') % (user, system, user + system, children)
        if self.registryValue('cpu.threads', target):
            response += format('I have spawned %n; I currently have %i still '
                               'running.',
                               (world.threadsSpawned, 'thread'), activeThreads)
        if self.registryValue('cpu.memory', target):
            mem = None
            pid = os.getpid()
            plat = sys.platform
            try:
                if plat.startswith('linux') or plat.startswith('sunos') or \
                   plat.startswith('freebsd') or plat.startswith('openbsd') or \
                   plat.startswith('darwin'):
                    cmd = 'ps -o rss -p %s' % pid
                    try:
                        inst = subprocess.Popen(cmd.split(), close_fds=True,
                                                stdin=open(os.devnull),
                                                stdout=subprocess.PIPE,
                                                stderr=subprocess.PIPE)
                    except __HOLE__:
                        irc.error(_('Unable to run ps command.'), Raise=True)
                    (out, foo) = inst.communicate()
                    inst.wait()
                    mem = int(out.splitlines()[1])
                elif sys.platform.startswith('netbsd'):
                    mem = int(os.stat('/proc/%s/mem' % pid)[7])
                if mem:
                    response += format(_('  I\'m taking up %S of memory.'),
                            mem*1024)
                else:
                    response += _('  I\'m taking up an unknown amount of memory.')
            except Exception:
                self.log.exception('Uncaught exception in cpu.memory:')
        irc.reply(utils.str.normalizeWhitespace(response))
dataset/ETHPy150Open ProgVal/Limnoria/plugins/Status/plugin.py/Status.cpu