コード例 #1
0
    def test_datetime(self):
        now = datetime.datetime.now()

        v = VARIANT()
        v.value = now
        self.failUnlessEqual(v.value, now)
        self.failUnlessEqual(v.vt, VT_DATE)
コード例 #2
0
    def get_data(self, scan, d_parameter):

        scan = c_long(scan)
        pvarLabels = VARIANT()
        pvarFlags = VARIANT()

        self.thermo_Library.GetLabelData(pvarLabels, pvarFlags, scan)
        scans_labels = numpy.array(pvarLabels.value)

        mz = scans_labels[0]
        magnitude = scans_labels[1]
        rp = scans_labels[2]
        base_noise = scans_labels[3]
        noise = scans_labels[4]
        # charge = scans_labels[5]

        array_noise_std = (numpy.array(noise) - numpy.array(base_noise)) / 3
        l_signal_to_noise = numpy.array(magnitude) / array_noise_std

        d_parameter["baselise_noise"] = numpy.average(array_noise_std)

        d_parameter["baselise_noise_std"] = numpy.average(array_noise_std)

        data_dict = {
            Labels.mz: mz,
            Labels.abundance: magnitude,
            Labels.rp: rp,
            Labels.s2n: l_signal_to_noise,
        }

        return data_dict
コード例 #3
0
    def test_decimal(self):
        pi = Decimal("3.13")

        v = VARIANT()
        v.value = pi
        self.failUnlessEqual(v.vt, VT_CY)
        self.failUnlessEqual(v.value, pi)
コード例 #4
0
ファイル: test_variant.py プロジェクト: 5Nap/Geometry
    def test_datetime(self):
        now = datetime.datetime.now()

        v = VARIANT()
        v.value = now
        self.failUnlessEqual(v.vt, VT_DATE)
        self.failUnlessEqual(v.value, now)
コード例 #5
0
def get_bounding_box(entity):
    min_point = VARIANT(array("d", array("d", [0, 0, 0])))
    max_point = VARIANT(array("d", array("d", [0, 0, 0])))
    ref_min_point = byref(min_point)
    ref_max_point = byref(max_point)
    entity.GetBoundingBox(ref_min_point, ref_max_point)
    return [array("d", list(*min_point)), array("d", list(*max_point))]
コード例 #6
0
 def test_int(self):
     import array
     for typecode in "bhiBHIlL":
         a = array.array(typecode, (1, 1, 1, 1))
         v = VARIANT()
         v.value = a
         self.failUnlessEqual(v.value, (1, 1, 1, 1))
コード例 #7
0
 def get_mass_list_from_scan_num(self, scan, minmz, maxmz):
     
     '''init_variable_from_get_spectrums
     # massList set up later
     '''
     
     scan = c_long(scan)
     scanFilter = u''
     scanIntensityCutoffType = c_long( 0) # 0 = none, 1=Abs, 2=Rel. to basepk
     scanIntensityCutoffValue = c_long( 0)
     scanMaxNumberOfPeaks = c_long( 0)
     scanCentroidResult = c_long( 0)
     peakFlags = VARIANT() #Unused variable
     # massList set up later
     arsize = c_long()
     
     data = array('f')
     
     massList = VARIANT()
     self.thermo_Library.GetMassListFromScanNum(
             scan,scanFilter,
             scanIntensityCutoffType,
             scanIntensityCutoffValue,
             scanMaxNumberOfPeaks,
             scanCentroidResult,
             c_double(0),
             massList,peakFlags,arsize
             )
         
         
     data = array(massList.value)
     return data[0], data[1]    
コード例 #8
0
    def test_datetime(self):
        now = datetime.datetime.now()

        v = VARIANT()
        v.value = now
        self.assertEqual(v.vt, VT_DATE)
        self.assertEqual(v.value, now)
コード例 #9
0
 def get_segment_mass_list_from_scan_num(self, scan):
     
     data = array('f')
     
     scan = c_long(scan)
     scanFilter = u''
     scanIntensityCutoffType = c_long( 0) # 0 = none, 1=Abs, 2=Rel. to basepk
     scanIntensityCutoffValue = c_long( 0)
     scanMaxNumberOfPeaks = c_long( 0)
     scanCentroidResult = c_long( 0)
     dCentroidPeakWidth = c_double( 0)
     massList = VARIANT()
     peakFlags = VARIANT()
     arsize = c_long()
     varSegments = VARIANT()
     NumSegments = c_long()
     varMassRange = VARIANT()
     
     self.thermo_Library.GetSegmentedMassListFromScanNum(
                                       scan, scanFilter,
                                       scanIntensityCutoffType,
                                       scanIntensityCutoffValue,
                                       scanMaxNumberOfPeaks, scanCentroidResult,
                                       dCentroidPeakWidth,
                                       massList,peakFlags,
                                       arsize, varSegments,
                                       NumSegments,
                                       varMassRange)
     
     data = array(massList.value)
         
     return data[0], data[1]
コード例 #10
0
    def test_decimal(self):
        pi = Decimal("3.13")

        v = VARIANT()
        v.value = pi
        self.failUnlessEqual(v.vt, VT_CY)
        self.failUnlessEqual(v.value, pi)
コード例 #11
0
ファイル: itpapi_i.py プロジェクト: bluewish/ProjectStudio
 def PutHardwareBreakPointer(self, index, addr, active=1, c_uiDID=0, privmask=0, slot=0,  
                             breaktype=u'Hardware', behavior=u'Execution', addrtype=u'IA32_PHY_PTR', dtsel=0, segsel=0, addrmask=0xffffffff):
     if self._itpBreakPointObj == None:
         return None
     
     if not self.DoesSupportBreakPointType('Hardware execution breakpoint'):
         return False
     
     #arr = [[VARIANT(0), VARIANT(1), ConvertToByteArray(addr, 8), VARIANT(1)]]
     
     arr = array.array('b')
     arr.fromlist([0L])
     bps = self._itpBreakPointObj.ReadBp(arr)
     print bps
     t = VARIANT()
     t.vt = comtypes.automation.VT_EMPTY
     t2 = VARIANT()
     t2.vt = comtypes.automation.VT_INT
     print self._itpBreakPointObj.QueryBpTypes(arr, 0x00000000L)
     self._itpBreakPointObj.WriteBp(bps)
     #arr = [0, 4, [segsel, ConvertToByteArray1(addr, 8), 0], 1]
     #try:
     #    arr = [[0, [5, 0], [segsel, addr, 0], 1]]
     #    self._itpBreakPointObj.WriteBp(arr)
     #except comtypes.COMError, hresult:
     #    print hresult
     #    return
     """
コード例 #12
0
ファイル: test_variant.py プロジェクト: nikmolnar/comtypes
 def test_int(self):
     import array
     for typecode in "bhiBHIlL":
         a = array.array(typecode, (1, 1, 1, 1))
         v = VARIANT()
         v.value = a
         self.failUnlessEqual(v.value, (1, 1, 1, 1))
コード例 #13
0
ファイル: test_variant.py プロジェクト: 5Nap/Geometry
    def test_decimal_as_currency(self):
        value = decimal.Decimal('3.14')

        v = VARIANT()
        v.value = value
        self.failUnlessEqual(v.vt, VT_CY)
        self.failUnlessEqual(v.value, value)
コード例 #14
0
ファイル: test_variant.py プロジェクト: nikmolnar/comtypes
 def test_double(self):
     import array
     for typecode in "df":
         # because of FLOAT rounding errors, whi will only work for
         # certain values!
         a = array.array(typecode, (1.0, 2.0, 3.0, 4.5))
         v = VARIANT()
         v.value = a
         self.failUnlessEqual(v.value, (1.0, 2.0, 3.0, 4.5))
コード例 #15
0
 def test_double(self):
     import array
     for typecode in "df":
         # because of FLOAT rounding errors, whi will only work for
         # certain values!
         a = array.array(typecode, (1.0, 2.0, 3.0, 4.5))
         v = VARIANT()
         v.value = a
         self.failUnlessEqual(v.value, (1.0, 2.0, 3.0, 4.5))
コード例 #16
0
ファイル: accessible_msaa.py プロジェクト: askalski/mats
def intToVariant(i):
    '''
    helper method, constructs Windows "VARIANT" object representing an integer
    '''
    v = VARIANT()
    v.vt = VT_I4
    v.value = i
    assert( isinstance(i, int) )
    return v
コード例 #17
0
ファイル: test_variant.py プロジェクト: 5Nap/Geometry
 def test_int(self):
     np = get_numpy()
     if np is None:
         return
     for dtype in ('int8', 'int16', 'int32', 'int64', 'uint8',
             'uint16', 'uint32', 'uint64'):
         a = np.array((1, 1, 1, 1), dtype=dtype)
         v = VARIANT()
         v.value = a
         self.failUnless((v.value == a).all())
コード例 #18
0
    def test_VARIANT_array(self):
        v = VARIANT()
        v.value = ((1, 2, 3), ("foo", "bar", None))
        self.failUnlessEqual(v.vt, VT_ARRAY | VT_VARIANT)
        self.failUnlessEqual(v.value, ((1, 2, 3), ("foo", "bar", None)))

        def func():
            v = VARIANT((1, 2, 3), ("foo", "bar", None))

        bytes = find_memleak(func)
        self.failIf(bytes, "Leaks %d bytes" % bytes)
コード例 #19
0
    def test_VARIANT_array(self):
        v = VARIANT()
        v.value = ((1, 2, 3), ("foo", "bar", None))
        self.failUnlessEqual(v.vt, VT_ARRAY | VT_VARIANT)
        self.failUnlessEqual(v.value, ((1, 2, 3), ("foo", "bar", None)))

        def func():
            v = VARIANT((1, 2, 3), ("foo", "bar", None))

        bytes = find_memleak(func)
        self.failIf(bytes, "Leaks %d bytes" % bytes)
コード例 #20
0
ファイル: test_variant.py プロジェクト: 5Nap/Geometry
    def test_mixed(self):
        np = get_numpy()
        if np is None:
            return

        now = datetime.datetime.now()
        a = np.array(
            [11, "22", None, True, now, decimal.Decimal("3.14")]).reshape(2,3)
        v = VARIANT()
        v.value = a
        self.failUnless((v.value == a).all())
コード例 #21
0
ファイル: test_variant.py プロジェクト: 5Nap/Geometry
 def test_double(self):
     np = get_numpy()
     if np is None:
         return
     for dtype in ('float32', 'float64'):
         # because of FLOAT rounding errors, whi will only work for
         # certain values!
         a = np.array([1.0, 2.0, 3.0, 4.5], dtype=dtype)
         v = VARIANT()
         v.value = a
         self.failUnless((v.value == a).all())
コード例 #22
0
    def test_BSTR(self):
        v = VARIANT()
        v.value = u"abc\x00123\x00"
        self.failUnlessEqual(v.value, "abc\x00123\x00")

        v.value = None
        # manually clear the variant
        v._.VT_I4 = 0

        # NULL pointer BSTR should be handled as empty string
        v.vt = VT_BSTR
        self.failUnless(v.value in ("", None))
コード例 #23
0
ファイル: test_variant.py プロジェクト: nikmolnar/comtypes
    def test_BSTR(self):
        v = VARIANT()
        v.value = u"abc\x00123\x00"
        self.failUnlessEqual(v.value, "abc\x00123\x00")

        v.value = None
        # manually clear the variant
        v._.VT_I4 = 0

        # NULL pointer BSTR should be handled as empty string
        v.vt = VT_BSTR
        self.failUnless(v.value in ("", None))
コード例 #24
0
ファイル: test_variant.py プロジェクト: 5Nap/Geometry
    def test_byref(self):
        variable = c_int(42)
        v = VARIANT(byref(variable))
        self.failUnlessEqual(v[0], 42)
        self.failUnlessEqual(v.vt, VT_BYREF | VT_I4)
        variable.value = 96
        self.failUnlessEqual(v[0], 96)

        variable = c_int(42)
        v = VARIANT(pointer(variable))
        self.failUnlessEqual(v[0], 42)
        self.failUnlessEqual(v.vt, VT_BYREF | VT_I4)
        variable.value = 96
        self.failUnlessEqual(v[0], 96)
コード例 #25
0
 def test_ctypes_in_variant(self):
     v = VARIANT()
     objs = [(c_ubyte(3), VT_UI1),
             (c_char("x"), VT_UI1),
             (c_byte(3), VT_I1),
             (c_ushort(3), VT_UI2),
             (c_short(3), VT_I2),
             (c_uint(3), VT_UI4),
             (c_int(3), VT_I4),
             (c_double(3.14), VT_R8),
             (c_float(3.14), VT_R4),
             ]
     for value, vt in objs:
         v.value = value
         self.failUnlessEqual(v.vt, vt)
コード例 #26
0
ファイル: test_variant.py プロジェクト: nikmolnar/comtypes
 def test_ctypes_in_variant(self):
     v = VARIANT()
     objs = [(c_ubyte(3), VT_UI1),
             (c_char("x"), VT_UI1),
             (c_byte(3), VT_I1),
             (c_ushort(3), VT_UI2),
             (c_short(3), VT_I2),
             (c_uint(3), VT_UI4),
             (c_int(3), VT_I4),
             (c_double(3.14), VT_R8),
             (c_float(3.14), VT_R4),
             ]
     for value, vt in objs:
         v.value = value
         self.failUnlessEqual(v.vt, vt)
コード例 #27
0
 def get_scans_labels(self):
    
     out = VARIANT()
     arsize = c_long()
     self.thermo_Library.GetFilters(out, arsize)
     scans_labels = numpy.array(out.value)
     return scans_labels, arsize 
コード例 #28
0
def AccessibleObjectFromPoint(x, y):
    "Return an accessible object and an index. See MSDN for details."
    pacc = POINTER(IAccessible)()
    var = VARIANT()
    oledll.oleacc.AccessibleObjectFromPoint(POINT(x, y), byref(pacc),
                                            byref(var))
    return pacc, var
コード例 #29
0
    def test_com_pointers(self):
        # Storing a COM interface pointer in a VARIANT increments the refcount,
        # changing the variant to contain something else decrements it
        tlb = LoadRegTypeLib(GUID("{00020430-0000-0000-C000-000000000046}"), 2, 0, 0)
        rc = get_refcnt(tlb)

        v = VARIANT(tlb)
        self.failUnlessEqual(get_refcnt(tlb), rc+1)

        p = v.value
        self.failUnlessEqual(get_refcnt(tlb), rc+2)
        del p
        self.failUnlessEqual(get_refcnt(tlb), rc+1)

        v.value = None
        self.failUnlessEqual(get_refcnt(tlb), rc)
コード例 #30
0
	def _get_UIAElementAtStartWithReplacedContent(self):
		"""Fetches the deepest UIAElement at the start of the text range whos name has been overridden by the author (such as aria-label)."""
		element=self.UIAElementAtStart
		condition=createUIAMultiPropertyCondition({UIAHandler.UIA_ControlTypePropertyId:self.UIAControlTypesWhereNameIsContent})
		# A part from the condition given, we must always match on the root of the document so we know when to stop walking
		runtimeID=VARIANT()
		self.obj.UIAElement._IUIAutomationElement__com_GetCurrentPropertyValue(UIAHandler.UIA_RuntimeIdPropertyId,byref(runtimeID))
		condition=UIAHandler.handler.clientObject.createOrCondition(UIAHandler.handler.clientObject.createPropertyCondition(UIAHandler.UIA_RuntimeIdPropertyId,runtimeID),condition)
		walker=UIAHandler.handler.clientObject.createTreeWalker(condition)
		cacheRequest=UIAHandler.handler.clientObject.createCacheRequest()
		cacheRequest.addProperty(UIAHandler.UIA_NamePropertyId)
		cacheRequest.addProperty(UIAHandler.UIA_AriaPropertiesPropertyId)
		element=walker.normalizeElementBuildCache(element,cacheRequest)
		while element and not UIAHandler.handler.clientObject.compareElements(element,self.obj.UIAElement):
			name=element.getCachedPropertyValue(UIAHandler.UIA_NamePropertyId)
			if name:
				ariaProperties=element.getCachedPropertyValue(UIAHandler.UIA_AriaPropertiesPropertyId)
				if ('label=' in ariaProperties)  or ('labelledby=' in ariaProperties):
					return element
				try:
					textRange=self.obj.UIATextPattern.rangeFromChild(element)
				except COMError:
					return
				text = textRange.getText(-1)
				if not text or text.isspace():
					return element
			element=walker.getParentElementBuildCache(element,cacheRequest)
コード例 #31
0
    def test_decimal_as_decimal(self):
        v = VARIANT()
        v.vt = VT_DECIMAL
        v.decVal.Lo64 = 1234
        v.decVal.scale = 3
        self.assertEqual(v.value, decimal.Decimal('1.234'))

        v.decVal.sign = 0x80
        self.assertEqual(v.value, decimal.Decimal('-1.234'))

        v.decVal.scale = 28
        self.assertEqual(v.value, decimal.Decimal('-1.234e-25'))

        v.decVal.scale = 12
        v.decVal.Hi32 = 100
        self.assertEqual(v.value, decimal.Decimal('-1844674407.370955162834'))
コード例 #32
0
ファイル: test_variant.py プロジェクト: nikmolnar/comtypes
    def test_integers(self):
        v = VARIANT()

        if (hasattr(sys, "maxint")):
            # this test doesn't work in Python 3000
            v.value = sys.maxint
            self.failUnlessEqual(v.value, sys.maxint)
            self.failUnlessEqual(type(v.value), int)

            v.value += 1
            self.failUnlessEqual(v.value, sys.maxint+1)
            self.failUnlessEqual(type(v.value), long)

        v.value = 1L
        self.failUnlessEqual(v.value, 1)
        self.failUnlessEqual(type(v.value), int)
コード例 #33
0
ファイル: mshtml.py プロジェクト: minghuascode/pyj
    def load_app(self):

        uri = self.application
        if uri.find(":") == -1:
            # assume file
            uri = 'file://' + os.path.abspath(uri)

        #print "load_app", uri

        self.application = uri
        v = byref(VARIANT())
        self.pBrowser.Navigate(uri, v, v, v, v)

        # Show Window
        cw = c_int(self.hwnd)
        ShowWindow(cw, c_int(SW_SHOW))
        UpdateWindow(cw)

        # http://msdn.microsoft.com/en-us/library/aa752126%28VS.85%29.aspx
        wba = self.pBrowser.QueryInterface(IServiceProvider)
        wn = wrap(wba.QueryService(SID_SShellBrowser, IOleWindow))

        hwnd = c_void_p(0)
        pHnd = byref(hwnd)
        wn.GetWindow(pHnd)

        #PostMessage(pHnd.value, WM_SETFOCUS,0,0)
        SetFocus(hwnd)
コード例 #34
0
    def test_integers(self):
        v = VARIANT()

        if (hasattr(sys, "maxint")):
            # this test doesn't work in Python 3000
            v.value = sys.maxsize
            self.assertEqual(v.value, sys.maxsize)
            self.assertEqual(type(v.value), int)

            v.value += 1
            self.assertEqual(v.value, sys.maxsize+1)
            self.assertEqual(type(v.value), int)

        v.value = 1
        self.assertEqual(v.value, 1)
        self.assertEqual(type(v.value), int)
コード例 #35
0
ファイル: test_variant.py プロジェクト: nikmolnar/comtypes
    def test_com_pointers(self):
        # Storing a COM interface pointer in a VARIANT increments the refcount,
        # changing the variant to contain something else decrements it
        tlb = LoadRegTypeLib(GUID("{00020430-0000-0000-C000-000000000046}"), 2, 0, 0)
        rc = get_refcnt(tlb)

        v = VARIANT(tlb)
        self.failUnlessEqual(get_refcnt(tlb), rc+1)

        p = v.value
        self.failUnlessEqual(get_refcnt(tlb), rc+2)
        del p
        self.failUnlessEqual(get_refcnt(tlb), rc+1)

        v.value = None
        self.failUnlessEqual(get_refcnt(tlb), rc)
コード例 #36
0
    def test_integers(self):
        v = VARIANT()

        if (hasattr(sys, "maxint")):
            # this test doesn't work in Python 3000
            v.value = sys.maxint
            self.failUnlessEqual(v.value, sys.maxint)
            self.failUnlessEqual(type(v.value), int)

            v.value += 1
            self.failUnlessEqual(v.value, sys.maxint+1)
            self.failUnlessEqual(type(v.value), long)

        v.value = 1L
        self.failUnlessEqual(v.value, 1)
        self.failUnlessEqual(type(v.value), int)
コード例 #37
0
 def get_label_data(self, scan):
     
     scan = c_long(scan)
     pvarLabels = VARIANT()
     pvarFlags = VARIANT()
     
     self.thermo_Library.GetLabelData(pvarLabels, pvarFlags, scan)
     scans_labels = numpy.array(pvarLabels.value)
     
     mz =        scans_labels[0]
     magnitude = scans_labels[1]
     resolution =        scans_labels[2]
     base_noise = scans_labels[3]
     noise =        scans_labels[4]
     charge = scans_labels[5]
     
     return mz, magnitude, resolution, base_noise, noise, charge
コード例 #38
0
    def test_decimal_as_decimal(self):
        v = VARIANT()
        v.vt = VT_DECIMAL
        v.decVal.Lo64 = 1234
        v.decVal.scale = 3
        self.failUnlessEqual(v.value, decimal.Decimal('1.234'))

        v.decVal.sign = 0x80
        self.failUnlessEqual(v.value, decimal.Decimal('-1.234'))

        v.decVal.scale = 28
        self.failUnlessEqual(v.value, decimal.Decimal('-1.234e-25'))

        v.decVal.scale = 12
        v.decVal.Hi32 = 100
        self.failUnlessEqual(
            v.value, decimal.Decimal('-1844674407.370955162834'))
コード例 #39
0
 def set_variant_matrix(self, value):
     if not self.is_nested_iterable(value):
         raise TypeError('Input data is not nested list/tuple.')
         
     if self.is_ragged(value):
         raise TypeError('Input data should not be a ragged array.')
         
     num_row = len(value)
     num_col = len(value[0])
     
     variant = VARIANT()
     _VariantClear(variant) # Clear the original data
     rgsa = (_safearray.SAFEARRAYBOUND * 2)()
     rgsa[0].cElements = num_row
     rgsa[0].lBound = 0
     rgsa[1].cElements = num_col
     rgsa[1].lBound = 0
                                             
     pa = _safearray.SafeArrayCreateEx(
         VT_VARIANT,
         2,
         rgsa,  # rgsaBound
         None)  # pvExtra
                                             
                                             
     if not pa:
         raise MemoryError()
 
     ptr = POINTER(VARIANT)()  # container for the values
     _safearray.SafeArrayAccessData(pa, byref(ptr))
     try:
         # I have no idea why 2D safearray is column-major.                
         index = 0
         for n in range(num_col):            
             for m in range(num_row):            
                 ptr[index] = value[m][n]
                 index += 1
     finally:
         _safearray.SafeArrayUnaccessData(pa)
     
     memmove(byref(variant._), byref(pa), sizeof(pa))  
     variant.vt = VT_ARRAY | VT_VARIANT
     return variant
コード例 #40
0
ファイル: modelnode.py プロジェクト: xialulee/WaveSyn
 def set_variant_matrix(self, value):
     if not self.is_nested_iterable(value):
         raise TypeError('Input data is not nested list/tuple.')
         
     if self.is_ragged(value):
         raise TypeError('Input data should not be a ragged array.')
         
     num_row = len(value)
     num_col = len(value[0])
     
     variant = VARIANT()
     _VariantClear(variant) # Clear the original data
     rgsa = (_safearray.SAFEARRAYBOUND * 2)()
     rgsa[0].cElements = num_row
     rgsa[0].lBound = 0
     rgsa[1].cElements = num_col
     rgsa[1].lBound = 0
                                             
     pa = _safearray.SafeArrayCreateEx(VT_VARIANT,
                                       2,
                                       rgsa,  # rgsaBound
                                       None)  # pvExtra
                                             
                                             
     if not pa:
         raise MemoryError()
 
     ptr = POINTER(VARIANT)()  # container for the values
     _safearray.SafeArrayAccessData(pa, byref(ptr))
     try:
         # I have no idea why 2D safearray is column-major.                
         index = 0
         for n in range(num_col):            
             for m in range(num_row):            
                 ptr[index] = value[m][n]
                 index += 1
     finally:
         _safearray.SafeArrayUnaccessData(pa)
     
     memmove(byref(variant._), byref(pa), sizeof(pa))  
     variant.vt = VT_ARRAY | VT_VARIANT
     return variant
コード例 #41
0
    def test_double_array(self):
        a = array.array("d", (3.14, 2.78))
        v = VARIANT(a)
        self.failUnlessEqual(v.vt, VT_ARRAY | VT_R8)
        self.failUnlessEqual(tuple(a.tolist()), v.value)

        def func():
            v = VARIANT(array.array("d", (3.14, 2.78)))

        bytes = find_memleak(func)
        self.failIf(bytes, "Leaks %d bytes" % bytes)
コード例 #42
0
 def AccessibleObjectFromPoint(x, y):
     """Return an accessible object and an index. See MSDN for details.
 @param  x  int  global pos
 @param  y  int  global pos
 @return  dict, int
 """
     pacc = POINTER(IAccessible)()
     var = VARIANT()
     oledll.oleacc.AccessibleObjectFromPoint(POINT(x, y), byref(pacc),
                                             byref(var))
     return pacc, var
コード例 #43
0
ファイル: test_variant.py プロジェクト: 5Nap/Geometry
    def test_datetime64(self):
        np = get_numpy()
        if np is None:
            return
        try:
            np.datetime64
        except AttributeError:
            return

        dates = [
            np.datetime64("2000-01-01T05:30:00", "s"),
            np.datetime64("1800-01-01T05:30:00", "ms"),
            np.datetime64("2000-01-01T12:34:56", "us")
        ]

        for date in dates:
            v = VARIANT()
            v.value = date
            self.failUnlessEqual(v.vt, VT_DATE)
            self.failUnlessEqual(v.value, date.astype(datetime.datetime))
コード例 #44
0
    def get_wia_files(self):
        device_mgr = CreateObject(progid='WiaDevMgr', interface=IWiaDevMgr)
        targets = [device_mgr.CreateDevice(self.id)]
        while targets:
            target = targets.pop()
            enum = target.EnumChildItems()
            NUM_OBJECTS_TO_REQUEST = 20
            num_fetched = NUM_OBJECTS_TO_REQUEST
            while num_fetched == NUM_OBJECTS_TO_REQUEST:
                items = (POINTER(IWiaItem) * NUM_OBJECTS_TO_REQUEST)()
                num_fetched = enum.Next(NUM_OBJECTS_TO_REQUEST, items)
                for i in xrange(num_fetched):
                    try:
                        item = items[i]
                        flags = item.GetItemType()
                        if flags & WIA_ITEM_TYPE_FOLDER:
                            targets.append(item)
                            continue
                        property_store = item.QueryInterface(IWiaPropertyStorage)
                        propspec = PROPSPEC()
                        propspec.ulKind = 1
                        propspec.u.propid = 4098
                        name = VARIANT()
                        property_store.ReadMultiple(1, byref(propspec), byref(name))
                        propspec.u.propid = 4123
                        ext = VARIANT()
                        property_store.ReadMultiple(1, byref(propspec), byref(ext))
                        try:
                            filename = name.value
                            if ext.value:
                                filename = filename + '.' + ext.value
                        except Exception:
                            unhandled_exc_handler()
                            continue

                        if not image_or_video(filename):
                            TRACE('Skipping %s, not photo or video', filename)
                            continue
                        try:
                            if ext.value and ext.value.lower() == 'bmp':
                                report_bad_assumption('Bitmap in a WIA device')
                                continue
                        except Exception:
                            unhandled_exc_handler()

                        propspec.u.propid = 4116
                        filesize = VARIANT()
                        property_store.ReadMultiple(1, byref(propspec), byref(filesize))
                        propspec.u.propid = 4100
                        filetime = PROPVARIANT()
                        property_store.ReadMultiple(1, byref(propspec), cast(byref(filetime), POINTER(VARIANT)))
                        spec_tymed = PROPSPEC()
                        spec_tymed.ulKind = 1
                        spec_tymed.u.propid = 4108
                        var_tymed = VARIANT()
                        var_tymed.value = 128
                        property_store.WriteMultiple(1, byref(spec_tymed), byref(var_tymed), 4098)
                        filetime = datetime_from_var_date(filetime)
                        yield WiaFile(id=filename, name=filename, size=filesize.value, mtime=filetime, wia_item=item)
                    except Exception as e:
                        self.handle_disconnect_exceptions(e)
                        unhandled_exc_handler()
コード例 #45
0
 def test_empty_BSTR(self):
     v = VARIANT()
     v.value = ""
     self.assertEqual(v.vt, VT_BSTR)