[pywin32-bugs] [ pywin32-Bugs-2052253 ] Problem calling WMI method
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2008-08-15 00:06:34
|
Bugs item #2052253, was opened at 2008-08-15 02:06 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=2052253&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Ramon Garcia (ramong) Assigned to: Nobody/Anonymous (nobody) Summary: Problem calling WMI method Initial Comment: An exception is issued if a WMI method call is attempted. The following code shows it. wmiservice = Dispatch("WbemScripting.SWbemLocator") wmi = wmiservice.ConnectServer("localhost", "root\cimv2") moniker = r"winmgmts:" \ "{impersonationLevel=impersonate,(Security,Backup)}!\\\\" + \ computer + r"\root\cimv2" wmi = GetObject(moniker) log_files = wmi.ExecQuery \ ("SELECT * FROM Win32_NTEventLogFile") for log_file in log_files: base = re.sub("event$", "", log_file.FileName) backup_filename = base + u".evt" log_file.BackupEventlog(backup_filename) The following exception is raised File "c:\python25\lib\site-packages\win32com\client\dynamic.py", line 495, in __getattr__ raise pythoncom.com_error, details com_error: (-2147352567, 'Ocurri\xf3 una excepci\xf3n.', (0, u'SWbemObjectEx', u'Invalid parameter ', None, 0, -2147217400), None) We traced this problem to WMI issing an unexecpected return code when it is attempted to get a property that is a method. The function __getattr__ in class CDispatch tries to resolve an attribute request as an attribute first, and then, if an error is raisen by COM, as a method: if details[0] in ERRORS_BAD_CONTEXT: # May be a method. self._olerepr_.mapFuncs[attr] = retEntry return self._make_method_(attr) raise pythoncom.com_error, details But the list of such errors seems not be enough. WMI is returning error code winerror.DISP_E_EXCEPTION in this case. We workarounded the problem adding winerror.DISP_E_EXCEPTION to ERRORS_BAD_CONTEXT in dynamic.py, but perhaps there is a more specific solution. Best regards Ramon Garcia ra...@cn... Comisin Nacional de Mercado de Valores ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=2052253&group_id=78018 |