本文整理汇总了Python中comtypes.COMError方法的典型用法代码示例。如果您正苦于以下问题:Python comtypes.COMError方法的具体用法?Python comtypes.COMError怎么用?Python comtypes.COMError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comtypes
的用法示例。
在下文中一共展示了comtypes.COMError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import comtypes [as 别名]
# 或者: from comtypes import COMError [as 别名]
def __init__(self, dirpath, **kwargs):
self.dirpath = dirpath
self.dirpath = os.path.abspath(self.dirpath)
self.dirpath = os.path.normpath(self.dirpath)
self.source = self.create_com_object()
self.filter = self.create_com_object_filter()
try:
self.source.OpenDataFile(self.dirpath)
except comtypes.COMError as err:
raise IOError(str(err))
self._TIC = self.source.GetTIC()
self.device = self._TIC.DeviceName
self._n_spectra = self._TIC.TotalDataPoints
self._scan_types_flags = self.source.MSScanFileInformation.ScanTypes
self._producer = self._scan_group_iterator()
self.initialize_scan_cache()
self._index = self._pack_index()
self._get_instrument_info()
示例2: as_text
# 需要导入模块: import comtypes [as 别名]
# 或者: from comtypes import COMError [as 别名]
def as_text(self):
try:
text = self._accessible.QueryInterface(pyia2.IA2Lib.IAccessibleText)
return AccessibleTextNode(text)
except comtypes.COMError:
return None
示例3: _get_child_count_safely
# 需要导入模块: import comtypes [as 别名]
# 或者: from comtypes import COMError [as 别名]
def _get_child_count_safely(self, i_accessible):
"""
Safely gets child count.
:param i_accessible: instance of i_accessible.
:rtype: int
:return: object child count
"""
try:
return i_accessible.accChildCount
except Exception as ex:
if isinstance(ex, comtypes.COMError) and getattr(ex, 'hresult') \
in (CO_E_OBJNOTCONNECTED,):
return 0
示例4: is_agilent_d_dir
# 需要导入模块: import comtypes [as 别名]
# 或者: from comtypes import COMError [as 别名]
def is_agilent_d_dir(path):
try:
AgilentDLoader(path)
return True
except (WindowsError, IOError, ImportError, COMError):
return False
示例5: determine_if_available
# 需要导入模块: import comtypes [as 别名]
# 或者: from comtypes import COMError [as 别名]
def determine_if_available():
try:
AgilentDLoader.create_com_object()
return True
except (WindowsError, COMError):
return False
示例6: _start_blocking
# 需要导入模块: import comtypes [as 别名]
# 或者: from comtypes import COMError [as 别名]
def _start_blocking(self):
# Import here so that it can be used in a background thread. The import
# must be run in the same thread as event registration and handling.
global comtypes, pyia2
import comtypes
import pyia2
# Register event listeners.
pyia2.Registry.registerEventListener(self._update_focus,
pyia2.EVENT_OBJECT_FOCUS)
# Perform all IAccessible2 operations as they are enqueued.
while not self.shutdown_event.is_set():
pyia2.Registry.iter_loop(0.01)
# Process events.
try:
self._process_focus_events()
except comtypes.COMError:
# Commonly occurs when the focus event no longer matches an active object.
pass
except Exception:
traceback.print_exc()
# Process closures.
while True:
try:
capture = self._closure_queue.get_nowait()
except queue.Empty:
break
try:
capture.return_value = capture.closure(self._context)
except base.AccessibilityError as exception:
capture.exception = exception
# Checked exception, don't print.
pass
except Exception as exception:
capture.exception = exception
# The stack trace won't be captured, so print here.
traceback.print_exc()
capture.done_event.set()
# Deregister event listeners.
pyia2.Registry.clearListeners()