def _find_mac(command, args, hw_identifiers, get_index):
    import os, shutil
    executable = shutil.which(command)
    if executable is None:
        path = os.pathsep.join(('/sbin', '/usr/sbin'))
        executable = shutil.which(command, path=path)
        if executable is None:
            return None

    try:
        # LC_ALL to ensure English output, 2>/dev/null to prevent output on
        # stderr (Note: we don't have an example where the words we search for
        # are actually localized, but in theory some system could do so.)
        cmd = 'LC_ALL=C %s %s 2>/dev/null' % (executable, args)
        with os.popen(cmd) as pipe:
            for line in pipe:
                words = line.lower().split()
                for i in range(len(words)):
                    if words[i] in hw_identifiers:
                        try:
                            return int(
                                words[get_index(i)].replace(':', ''), 16)
                        except (ValueError, IndexError):
                            # Virtual interfaces, such as those provided by
                            # VPNs, do not have a colon-delimited MAC address
                            # as expected, but a 16-byte HWAddr separated by
                            # dashes. These should be ignored in favor of a
                            # real MAC address
                            pass
    except OSError:
        pass
dataset/ETHPy150Open amrdraz/kodr/app/brython/www/src/Lib/uuid.py/_find_mac/original