def get_interface_info(_fd, iface): log = logger() from xpra.platform.win32.comtypes_util import QuietenLogging with QuietenLogging(): try: from comtypes import CoInitialize #@UnresolvedImport CoInitialize() from comtypes.client import CreateObject #@UnresolvedImport o = CreateObject("WbemScripting.SWbemLocator") s = o.ConnectServer(".", "root\\cimv2") query = "SELECT * FROM Win32_NetworkAdapter WHERE GUID='%s'" % iface res = s.ExecQuery(query) log("ExecQuery(%s) returned %i rows", query, res.Count) if res.Count == 1: for r in res: props = {} for k, ik, conv in ( ("AdapterType", "adapter-type", str), ("Caption", "caption", str), ("Description", "description", str), ("DeviceID", "id", int), ("GUID", "GUID", str), ("Index", "index", int), ("Name", "name", str), ("ProductName", "product-name", str), ("Speed", "speed", int), ): try: v = conv(r.Properties_[k].Value) except Exception as e: log.error( "Error retrieving '%s' from network adapter record:", k) log.error(" %s", e) else: props[ik] = v log("get_interface_info(%s)=%s" % (iface, props)) return props except Exception as e: log("get_interface_info(%s)", iface, exc_info=True) from xpra.util import first_time if first_time("win32-network-query"): log.error("Error: failed to query network interface:") log.error(" %s", e) return {}
dirs = [ app_dir, os.path.join(app_dir, "win32"), os.path.join(app_dir, "share", "xpra") ] filenames = [os.environ.get("XPRA_DIRECTSHOW_TLB") ] + [os.path.join(d, "DirectShow.tlb") for d in dirs] for filename in filenames: if filename and os.path.exists(filename): directshow_tlb = filename break log("directshow_tlb=%s", directshow_tlb) if not directshow_tlb: raise ImportError("DirectShow.tlb is missing") with QuietenLogging(): directshow = client.GetModule(directshow_tlb) log("directshow: %s", directshow) log("directshow: %s", dir(directshow)) CLSID_VideoInputDeviceCategory = comtypes.GUID( "{860BB310-5D01-11d0-BD3B-00A0C911CE86}") CLSID_SystemDeviceEnum = comtypes.GUID( '{62BE5D10-60EB-11d0-BD3B-00A0C911CE86}') class DeviceEnumerator(comtypes.CoClass): _reg_clsid_ = CLSID_SystemDeviceEnum _com_interfaces_ = [directshow.ICreateDevEnum] _idlflags_ = [] _typelib_path_ = "E:\\DirectShow.tlb" #typelib_path