def _make_ping(command):
        def f(self, irc, msg, args, optlist, host):
            """[--c <count>] [--i <interval>] [--t <ttl>] [--W <timeout>] [--4|--6] <host or ip>

            Sends an ICMP echo request to the specified host.
            The arguments correspond with those listed in ping(8). --c is
            limited to 10 packets or less (default is 5). --i is limited to 5
            or less. --W is limited to 10 or less.
            --4 and --6 can be used if and only if the system has a unified
            ping command.
            """
            pingCmd = self.registryValue(registry.join([command, 'command']))
            if not pingCmd:
               irc.error('The ping command is not configured.  If one '
                         'is installed, reconfigure '
                         'supybot.plugins.Unix.%s.command appropriately.' %
                         command, Raise=True)
            else:
                try: host = host.group(0)
                except __HOLE__: pass

                args = [pingCmd]
                for opt, val in optlist:
                    if opt == 'c' and val > 10: val = 10
                    if opt == 'i' and val >  5: val = 5
                    if opt == 'W' and val > 10: val = 10
                    args.append('-%s' % opt)
                    if opt not in ('4', '6'):
                        args.append(str(val))
                if '-c' not in args:
                    args.append('-c')
                    args.append('5')
                args.append(host)
                try:
                    with open(os.devnull) as null:
                        inst = subprocess.Popen(args,
                                                stdout=subprocess.PIPE,
                                                stderr=subprocess.PIPE,
                                                stdin=null)
                except OSError as e:
                    irc.error('It seems the configured ping command was '
                              'not available (%s).' % e, Raise=True)
                result = inst.communicate()
                if result[1]: # stderr
                    irc.error(' '.join(result[1].decode('utf8').split()))
                else:
                    response = result[0].decode('utf8').split("\n");
                    if response[1]:
                        irc.reply(' '.join(response[1].split()[3:5]).split(':')[0]
                                  + ': ' + ' '.join(response[-3:]))
                    else:
                        irc.reply(' '.join(response[0].split()[1:3])
                                  + ': ' + ' '.join(response[-3:]))

        f.__name__ = command
        _hostExpr = re.compile(r'^[a-z0-9][a-z0-9\.-]*[a-z0-9]$', re.I)
        return thread(wrap(f, [getopts({'c':'positiveInt','i':'float',
                                        't':'positiveInt','W':'positiveInt',
                                        '4':'', '6':''}),
                           first('ip', ('matches', _hostExpr, 'Invalid hostname'))]))
dataset/ETHPy150Open ProgVal/Limnoria/plugins/Unix/plugin.py/Unix._make_ping