MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / get

Method get

pager_lib/getmac/getmac.py:758–772  ·  view source on GitHub ↗
(self, arg)

Source from the content-addressed store, hash-verified

756 return False
757
758 def get(self, arg): # type: (str) -> Optional[str]
759 import fcntl
760
761 if not PY2:
762 arg = arg.encode() # type: ignore
763
764 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
765
766 # 0x8927 = SIOCGIFADDR
767 info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack("256s", arg[:15]))
768
769 if PY2:
770 return ":".join(["%02x" % ord(char) for char in info[18:24]])
771 else:
772 return ":".join(["%02x" % ord(chr(char)) for char in info[18:24]])
773
774
775class GetmacExe(Method):

Callers

nothing calls this directly

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected