mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 18:47:09 -07:00
Update jaraco-windows to 3.9.2
Also updates: - importlib-metadata-0.7 - jaraco-windows - jaraco.classes-1.5 - jaraco.collections-1.6.0 - jaraco.functools-1.20 - jaraco.structures-1.1.2 - jaraco.text-1.10.1 - jaraco.ui-1.6 - more-itertools-4.3.0 - path.py-11.5.0 - six-1.12.0
This commit is contained in:
parent
aa769627bd
commit
8d43b8ea39
92 changed files with 7515 additions and 996 deletions
|
@ -14,20 +14,21 @@ from jaraco.windows.api import errors, inet
|
|||
|
||||
def GetAdaptersAddresses():
|
||||
size = ctypes.c_ulong()
|
||||
res = inet.GetAdaptersAddresses(0,0,None, None,size)
|
||||
res = inet.GetAdaptersAddresses(0, 0, None, None, size)
|
||||
if res != errors.ERROR_BUFFER_OVERFLOW:
|
||||
raise RuntimeError("Error getting structure length (%d)" % res)
|
||||
print(size.value)
|
||||
pointer_type = ctypes.POINTER(inet.IP_ADAPTER_ADDRESSES)
|
||||
buffer = ctypes.create_string_buffer(size.value)
|
||||
struct_p = ctypes.cast(buffer, pointer_type)
|
||||
res = inet.GetAdaptersAddresses(0,0,None, struct_p, size)
|
||||
res = inet.GetAdaptersAddresses(0, 0, None, struct_p, size)
|
||||
if res != errors.NO_ERROR:
|
||||
raise RuntimeError("Error retrieving table (%d)" % res)
|
||||
while struct_p:
|
||||
yield struct_p.contents
|
||||
struct_p = struct_p.contents.next
|
||||
|
||||
|
||||
class AllocatedTable(object):
|
||||
"""
|
||||
Both the interface table and the ip address table use the same
|
||||
|
@ -79,20 +80,23 @@ class AllocatedTable(object):
|
|||
on the table size.
|
||||
"""
|
||||
table = self.get_table()
|
||||
entries_array = self.row_structure*table.num_entries
|
||||
entries_array = self.row_structure * table.num_entries
|
||||
pointer_type = ctypes.POINTER(entries_array)
|
||||
return ctypes.cast(table.entries, pointer_type).contents
|
||||
|
||||
|
||||
class InterfaceTable(AllocatedTable):
|
||||
method = inet.GetIfTable
|
||||
structure = inet.MIB_IFTABLE
|
||||
row_structure = inet.MIB_IFROW
|
||||
|
||||
|
||||
class AddressTable(AllocatedTable):
|
||||
method = inet.GetIpAddrTable
|
||||
structure = inet.MIB_IPADDRTABLE
|
||||
row_structure = inet.MIB_IPADDRROW
|
||||
|
||||
|
||||
class AddressManager(object):
|
||||
@staticmethod
|
||||
def hardware_address_to_string(addr):
|
||||
|
@ -100,7 +104,8 @@ class AddressManager(object):
|
|||
return ':'.join(hex_bytes)
|
||||
|
||||
def get_host_mac_address_strings(self):
|
||||
return (self.hardware_address_to_string(addr)
|
||||
return (
|
||||
self.hardware_address_to_string(addr)
|
||||
for addr in self.get_host_mac_addresses())
|
||||
|
||||
def get_host_ip_address_strings(self):
|
||||
|
@ -110,10 +115,10 @@ class AddressManager(object):
|
|||
return (
|
||||
entry.physical_address
|
||||
for entry in InterfaceTable().entries
|
||||
)
|
||||
)
|
||||
|
||||
def get_host_ip_addresses(self):
|
||||
return (
|
||||
entry.address
|
||||
for entry in AddressTable().entries
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue