本文整理匯總了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()