Hello, I'm occasionally receiving the following error when doing a set of queries:
Traceback (most recent call last): File "psg5220_demo.py", line 236, in find_hdd_drives partitions = services.query(query) File "...path..\wmi.py", line 889, in query return [ _wmi_object (obj, instance_of, fields) for obj in self._raw_query(w ql) ] File "C:\Python26\lib\site-packages\win32com\client\util.py", line 84, in next return _get_good_object_(self._iter_.next(), resultCLSID = self.resultCLSID) pywintypes.com_error: (-2147217406, 'OLE error 0x80041002', None, None) The code being run is as follows: try: #Setup the WMI handle. services = wmi.WMI('.', moniker="winmgmts:{impersonationLevel=impersonate,(security)}", find_classes=True) # loop over physical disks and get serial numbers for disk in services.Win32_PhysicalMedia(): serials[disk.Tag] = disk.SerialNumber serials_reversed[disk.Tag] = disk.SerialNumber # get the physical <-> drive letter mapping for disk in services.Win32_DiskDrive(): query = "ASSOCIATORS OF {Win32_DiskDrive.DeviceID=\"%s\"} " \ % disk.DeviceID #re.sub(r"\\", r"\\\\", disk.DeviceID) query += "WHERE AssocClass = Win32_DiskDriveToDiskPartition " partitions = services.query(query) for part in partitions: query = "ASSOCIATORS OF {Win32_DiskPartition.DeviceID='%s'} " \ % part.DeviceID query += "WHERE AssocClass = Win32_LogicalDiskToPartition" logical_drives = services.query(query) for logical_drive in logical_drives: drive_letter = re.sub(":", "", logical_drive.DeviceID) drive_letters[drive_letter] = disk.DeviceID This is on Windows XP and Vista both. It sometimes happens once then not again for 50 tries. Sometimes it happens 5 times in a row. It appears that an "OLE Error 0x80041002" is an "object not found error". So the query is running and line 86 in util.py is trying to get the next result from the query and is bombing out? For some reason it things there are more results then there actually are? This code is a direct port from working Perl code. Anyone have any ideas? _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32