mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-22 10:52:17 +03:00
macaddress method changed
This commit is contained in:
parent
5692e21b62
commit
70092dd737
1 changed files with 21 additions and 13 deletions
|
@ -504,20 +504,28 @@ class System:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def mac_addresses():
|
def mac_addresses():
|
||||||
mac = get_mac()
|
mac_addresses = []
|
||||||
':'.join(("%012X" % mac)[i:i + 2] for i in range(0, 12, 2))
|
nics = psutil.net_if_addrs()
|
||||||
arr = []
|
nics.pop('lo') # remove loopback since it doesnt have a real mac address
|
||||||
for iface in psutil.net_io_counters(pernic=True):
|
|
||||||
try:
|
|
||||||
addr_list = psutil.net_if_addrs()
|
|
||||||
mac = addr_list[str(iface)][2][1]
|
|
||||||
if re.match("[0-9a-f]{2}([-:])[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", mac.lower()) and str(
|
|
||||||
mac) != '00:00:00:00:00:00':
|
|
||||||
arr.append(mac.lower())
|
|
||||||
except Exception as e:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return arr
|
for i in nics:
|
||||||
|
for j in nics[i]:
|
||||||
|
if j.family == 17: # AF_LINK
|
||||||
|
mac_addresses.append(j.address)
|
||||||
|
return mac_addresses
|
||||||
|
# mac = get_mac()
|
||||||
|
# ':'.join(("%012X" % mac)[i:i + 2] for i in range(0, 12, 2))
|
||||||
|
# arr = []
|
||||||
|
# for iface in psutil.net_io_counters(pernic=True):
|
||||||
|
# try:
|
||||||
|
# addr_list = psutil.net_if_addrs()
|
||||||
|
# mac = addr_list[str(iface)][2][1]
|
||||||
|
# if re.match("[0-9a-f]{2}([-:])[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", mac.lower()) and str(
|
||||||
|
# mac) != '00:00:00:00:00:00':
|
||||||
|
# arr.append(mac.lower())
|
||||||
|
# except Exception as e:
|
||||||
|
# pass
|
||||||
|
# return arr
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def screen_info_json_obj(info):
|
def screen_info_json_obj(info):
|
||||||
|
|
Loading…
Reference in a new issue