(self, arg)
| 581 | return check_command("arping") |
| 582 | |
| 583 | def get(self, arg): # type: (str) -> Optional[str] |
| 584 | # If busybox or iputils, this will just work, and if host ping fails, |
| 585 | # then it'll exit with code 1 and this function will return None. |
| 586 | # |
| 587 | # If it's Habets, then it'll exit code 1 and have "invalid option" |
| 588 | # and/or the help message in the output. |
| 589 | # In the case of Habets, set self._is_iputils to False, |
| 590 | # then re-try with Habets args. |
| 591 | try: |
| 592 | if self._is_iputils: |
| 593 | command_output = _popen("arping", self._iputils_args % arg) |
| 594 | if command_output: |
| 595 | return _search( |
| 596 | r" from %s \[(%s)\]" % (re.escape(arg), MAC_RE_COLON), |
| 597 | command_output, |
| 598 | ) |
| 599 | else: |
| 600 | return self._call_habets(arg) |
| 601 | except CalledProcessError as ex: |
| 602 | if ex.output and self._is_iputils: |
| 603 | if not PY2 and isinstance(ex.output, bytes): |
| 604 | output = str(ex.output, "utf-8").lower() |
| 605 | else: |
| 606 | output = str(ex.output).lower() |
| 607 | |
| 608 | if "habets" in output or "invalid option" in output: |
| 609 | if DEBUG: |
| 610 | log.debug("Falling back to Habets arping") |
| 611 | self._is_iputils = False |
| 612 | try: |
| 613 | return self._call_habets(arg) |
| 614 | except CalledProcessError: |
| 615 | pass |
| 616 | |
| 617 | return None |
| 618 | |
| 619 | def _call_habets(self, arg): # type: (str) -> Optional[str] |
| 620 | command_output = _popen("arping", self._habets_args % arg) |
nothing calls this directly
no test coverage detected