当前位置: 首页>>代码示例>>Python>>正文


Python ctypes.c_uint32方法代码示例

本文整理汇总了Python中ctypes.c_uint32方法的典型用法代码示例。如果您正苦于以下问题:Python ctypes.c_uint32方法的具体用法?Python ctypes.c_uint32怎么用?Python ctypes.c_uint32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ctypes的用法示例。


在下文中一共展示了ctypes.c_uint32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ConfigureIOKit

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint32 [as 别名]
def ConfigureIOKit():
  """Sets up IOKit.

  We use ctypes to call functions in shared libraries to create, access and
  manipulate C data types in Python. For more information about ctypes, see:

  http://python.net/crew/theller/ctypes/
  http://code.rancidbacon.com/LearningAboutMacOSXNativePythonProgramming

  Returns:
    io_lib: IOKit library
  """
  io_lib = ctypes.cdll.LoadLibrary(
      '/System/Library/Frameworks/IOKit.framework/IOKit')
  io_lib.IOPMAssertionCreateWithName.argtypes = [
      ctypes.c_void_p,
      ctypes.c_uint32,
      ctypes.c_void_p,
      ctypes.POINTER(ctypes.c_uint32)]
  io_lib.IOPMAssertionRelease.argtypes = [ctypes.c_uint32]
  return io_lib 
开发者ID:google,项目名称:macops,代码行数:23,代码来源:gmacpyutil.py

示例2: __init__

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint32 [as 别名]
def __init__(self):
        # Locate libnss and try loading it
        self.NSS = None
        self.load_libnss()

        SlotInfoPtr = ct.POINTER(self.PK11SlotInfo)
        SECItemPtr = ct.POINTER(self.SECItem)

        self._set_ctypes(ct.c_int, "NSS_Init", ct.c_char_p)
        self._set_ctypes(ct.c_int, "NSS_Shutdown")
        self._set_ctypes(SlotInfoPtr, "PK11_GetInternalKeySlot")
        self._set_ctypes(None, "PK11_FreeSlot", SlotInfoPtr)
        self._set_ctypes(ct.c_int, "PK11_CheckUserPassword", SlotInfoPtr, ct.c_char_p)
        self._set_ctypes(ct.c_int, "PK11SDR_Decrypt", SECItemPtr, SECItemPtr, ct.c_void_p)
        self._set_ctypes(None, "SECITEM_ZfreeItem", SECItemPtr, ct.c_int)

        # for error handling
        self._set_ctypes(ct.c_int, "PORT_GetError")
        self._set_ctypes(ct.c_char_p, "PR_ErrorToName", ct.c_int)
        self._set_ctypes(ct.c_char_p, "PR_ErrorToString", ct.c_int, ct.c_uint32) 
开发者ID:unode,项目名称:firefox_decrypt,代码行数:22,代码来源:firefox_decrypt.py

示例3: _ar_arsdk_encode_type_info

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint32 [as 别名]
def _ar_arsdk_encode_type_info(cls, ar_argtype):
        arsdk_encode_type_info_map = {
            arsdkparser.ArArgType.I8: (od.ARSDK_ARG_TYPE_I8, "i8", ctypes.c_int8),
            arsdkparser.ArArgType.U8: (od.ARSDK_ARG_TYPE_U8, "u8", ctypes.c_uint8),
            arsdkparser.ArArgType.I16: (od.ARSDK_ARG_TYPE_I16, "i16", ctypes.c_int16),
            arsdkparser.ArArgType.U16: (od.ARSDK_ARG_TYPE_U16, "u16", ctypes.c_uint16),
            arsdkparser.ArArgType.I32: (od.ARSDK_ARG_TYPE_I32, "i32", ctypes.c_int32),
            arsdkparser.ArArgType.U32: (od.ARSDK_ARG_TYPE_U32, "u32", ctypes.c_uint32),
            arsdkparser.ArArgType.I64: (od.ARSDK_ARG_TYPE_I64, "i64", ctypes.c_int64),
            arsdkparser.ArArgType.U64: (od.ARSDK_ARG_TYPE_U64, "u64", ctypes.c_uint64),
            arsdkparser.ArArgType.FLOAT: (od.ARSDK_ARG_TYPE_FLOAT, "f32", ctypes.c_float),
            arsdkparser.ArArgType.DOUBLE: (od.ARSDK_ARG_TYPE_DOUBLE, "f64", ctypes.c_double),
            arsdkparser.ArArgType.STRING: (od.ARSDK_ARG_TYPE_STRING, "cstr", od.char_pointer_cast),
            arsdkparser.ArArgType.ENUM: (od.ARSDK_ARG_TYPE_ENUM, "i32", ctypes.c_int32),
        }
        return arsdk_encode_type_info_map[ar_argtype] 
开发者ID:Parrot-Developers,项目名称:olympe,代码行数:18,代码来源:messages.py

示例4: test_padded_union

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint32 [as 别名]
def test_padded_union(self):
        dt = np.dtype(dict(
            names=['a', 'b'],
            offsets=[0, 0],
            formats=[np.uint16, np.uint32],
            itemsize=5,
        ))

        ct = np.ctypeslib.as_ctypes_type(dt)
        assert_(issubclass(ct, ctypes.Union))
        assert_equal(ctypes.sizeof(ct), dt.itemsize)
        assert_equal(ct._fields_, [
            ('a', ctypes.c_uint16),
            ('b', ctypes.c_uint32),
            ('', ctypes.c_char * 5),  # padding
        ]) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:18,代码来源:test_ctypeslib.py

示例5: test_union_with_struct_packed

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint32 [as 别名]
def test_union_with_struct_packed(self):
        class Struct(ctypes.Structure):
            _pack_ = 1
            _fields_ = [
                ('one', ctypes.c_uint8),
                ('two', ctypes.c_uint32)
            ]

        class Union(ctypes.Union):
            _fields_ = [
                ('a', ctypes.c_uint8),
                ('b', ctypes.c_uint16),
                ('c', ctypes.c_uint32),
                ('d', Struct),
            ]
        expected = np.dtype(dict(
            names=['a', 'b', 'c', 'd'],
            formats=['u1', np.uint16, np.uint32, [('one', 'u1'), ('two', np.uint32)]],
            offsets=[0, 0, 0, 0],
            itemsize=ctypes.sizeof(Union)
        ))
        self.check(Union, expected) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:24,代码来源:test_dtype.py

示例6: test_large_packed_structure

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint32 [as 别名]
def test_large_packed_structure(self):
        class PackedStructure(ctypes.Structure):
            _pack_ = 2
            _fields_ = [
                ('a', ctypes.c_uint8),
                ('b', ctypes.c_uint16),
                ('c', ctypes.c_uint8),
                ('d', ctypes.c_uint16),
                ('e', ctypes.c_uint32),
                ('f', ctypes.c_uint32),
                ('g', ctypes.c_uint8)
                ]
        expected = np.dtype(dict(
            formats=[np.uint8, np.uint16, np.uint8, np.uint16, np.uint32, np.uint32, np.uint8 ],
            offsets=[0, 2, 4, 6, 8, 12, 16],
            names=['a', 'b', 'c', 'd', 'e', 'f', 'g'],
            itemsize=18))
        self.check(PackedStructure, expected) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:test_dtype.py

示例7: getch_impl

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint32 [as 别名]
def getch_impl():
    # TODO: This windows impl keeps pipes/redirects from working. Need ReadFile for that,
    # with more complicated handling (personally, I'm just going to keep using unix/cygwin
    # for pipe-y debug stuff...)
    # TODO: Windows escape seqs via ReadConsoleInput, convert to VT100 seqs for more commonality.
    if is_windows:
        stdin_handle = ctypes.windll.kernel32.GetStdHandle(ctypes.c_ulong(-10))
        one_char_buf = ctypes.c_uint32()
        chars_read = ctypes.c_uint32()
        # NOTE: W version of this function == ERROR_NOACCESS after text color set in photopia!?
        result = ctypes.windll.kernel32.ReadConsoleA(stdin_handle,
                                                     ctypes.byref(one_char_buf),
                                                     1,
                                                     ctypes.byref(chars_read),
                                                     0)

        if result == 0 or chars_read.value != 1:
            last_err = ctypes.windll.kernel32.GetLastError()
            print('LAST ERR', last_err)
            err('failed to read console')

        return chr(one_char_buf.value)
    else: #Unix
        return sys.stdin.read(1) 
开发者ID:theinternetftw,项目名称:xyppy,代码行数:26,代码来源:term.py

示例8: get_netmask

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint32 [as 别名]
def get_netmask(self):
        """
        Get ip network netmask
        """
        if not CTYPES_SUPPORT:
            raise exceptions.TestSkipError("Getting the netmask requires "
                                           "python > 2.4")
        ifreq = struct.pack('16sH14s', self.name.encode(),
                            socket.AF_INET, b'\x00' * 14)
        try:
            res = fcntl.ioctl(sockfd, arch.SIOCGIFNETMASK, ifreq)
        except IOError:
            return 0
        netmask = socket.ntohl(struct.unpack('16sH2xI8x', res)[2])

        return 32 - int(math.log(ctypes.c_uint32(~netmask).value + 1, 2)) 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:18,代码来源:utils_net.py

示例9: win32_path_short

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint32 [as 别名]
def win32_path_short (self, path):
		if not path:
			return ''
		path = os.path.abspath(path)
		if self.unix:
			return path
		self._win32_load_kernel()
		if not self.GetShortPathName:
			try:
				import ctypes
				self.GetShortPathName = self.kernel32.GetShortPathNameA
				args = [ ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int32 ]
				self.GetShortPathName.argtypes = args
				self.GetShortPathName.restype = ctypes.c_uint32
			except: pass
		if not self.GetShortPathName:
			return path
		retval = self.GetShortPathName(path, self.textdata, 2048)
		shortpath = self.textdata.value
		if retval <= 0:
			import ctypes
			print 'ERROR(%d): %s'%(ctypes.GetLastError(), path)
			return ''
		return shortpath 
开发者ID:skywind3000,项目名称:terminal,代码行数:26,代码来源:terminal.py

示例10: win32_path_full

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint32 [as 别名]
def win32_path_full (self, path):
		if not path:
			return ''
		path = os.path.abspath(path)
		if self.unix:
			return path
		self._win32_load_kernel()
		if not self.GetFullPathName:
			try:
				import ctypes
				self.GetFullPathName = self.kernel32.GetFullPathNameA
				args = [ ctypes.c_char_p, ctypes.c_int32, ctypes.c_char_p ]
				self.GetFullPathName.argtypes = args + [ctypes.c_char_p]
				self.GetFullPathName.restype = ctypes.c_uint32
			except: pass
		if not self.GetFullPathName:
			return path
		retval = self.GetFullPathName(path, 2048, self.textdata, None)
		fullpath = self.textdata.value
		if retval <= 0:
			return ''
		return fullpath

	# win32 get long pathname 
开发者ID:skywind3000,项目名称:terminal,代码行数:26,代码来源:terminal.py

示例11: win32_path_long

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint32 [as 别名]
def win32_path_long (self, path):
		if not path:
			return ''
		path = os.path.abspath(path)
		if self.unix:
			return path
		self._win32_load_kernel()
		if not self.GetLongPathName:
			try:
				import ctypes
				self.GetLongPathName = self.kernel32.GetLongPathNameA
				args = [ ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int32 ]
				self.GetLongPathName.argtypes = args
				self.GetLongPathName.restype = ctypes.c_uint32
			except: pass
		if not self.GetLongPathName:
			return path
		retval = self.GetLongPathName(path, self.textdata, 2048)
		longpath = self.textdata.value
		if retval <= 0:
			return ''
		return longpath 
开发者ID:skywind3000,项目名称:terminal,代码行数:24,代码来源:terminal.py

示例12: _python_get_unit_info

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint32 [as 别名]
def _python_get_unit_info(self, handle, info_type):
        string_size = 255
        info = self._create_empty_string_buffer()
        if len(self._get_unit_info.argtypes) == 4:
            info_len = self._get_unit_info(c_int16(handle), info, c_int16(string_size), c_int16(info_type))
            if info_len > 0:
                return info.value[:info_len]
        elif len(self._get_unit_info.argtypes) == 5:
            required_size = c_int16(0)
            status = self._get_unit_info(c_int16(handle),
                                         info,
                                         c_int16(string_size),
                                         byref(required_size),
                                         c_uint32(info_type))
            if status == self.PICO_STATUS['PICO_OK']:
                if required_size.value < string_size:
                    return info.value[:required_size.value]
        return "" 
开发者ID:picotech,项目名称:picosdk-python-wrappers,代码行数:20,代码来源:library.py

示例13: set_null_trigger

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint32 [as 别名]
def set_null_trigger(self, device):
        auto_trigger_after_millis = 1
        if hasattr(self, '_set_trigger') and len(self._set_trigger.argtypes) == 6:
            PS2000_NONE = 5
            return_code = self._set_trigger(c_int16(device.handle),
                                            c_int16(PS2000_NONE),
                                            c_int16(0),
                                            c_int16(0),
                                            c_int16(0),
                                            c_int16(auto_trigger_after_millis))
            if return_code == 0:
                raise InvalidTriggerParameters()
        elif hasattr(self, '_set_simple_trigger') and len(self._set_simple_trigger.argtypes) == 7:
            enabled = False
            status = self._set_simple_trigger(c_int16(device.handle),
                                              c_int16(int(enabled)),
                                              c_int32(self.PICO_CHANNEL['A']),
                                              c_int16(0),
                                              c_int32(self.PICO_THRESHOLD_DIRECTION['NONE']),
                                              c_uint32(0),
                                              c_int16(auto_trigger_after_millis))
            if status != self.PICO_STATUS['PICO_OK']:
                raise InvalidTriggerParameters("set_simple_trigger failed (%s)" % constants.pico_tag(status))
        else:
            raise NotImplementedError("not done other driver types yet") 
开发者ID:picotech,项目名称:picosdk-python-wrappers,代码行数:27,代码来源:library.py

示例14: NOTplatformPs

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint32 [as 别名]
def NOTplatformPs(self):
        ctl = SysctlType()
        ctl.one = CTL_KERN
        ctl.two = KERN_PROC
        ctl.three = KERN_PROC_ALL

        size = ctypes.c_uint32()
        self.libc.sysctl(addrof(ctl), 3, None, addrof(size), None, 0)
        count = size.value / ctypes.sizeof(kinfo_proc)
        buf = (kinfo_proc * count)()
        self.libc.sysctl(addrof(ctl), 3, buf,  addrof(size), None, 0)
        ret = []
        for i in range(count):
            pid = buf[i].kp_proc.p_pid
            if pid == 0: # Skip the crazy kernel things...
                continue
            name = buf[i].kp_proc.p_comm
            ret.append((pid,name))
        ret.reverse()
        return ret 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:22,代码来源:darwin.py

示例15: platformGetRegCtx

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint32 [as 别名]
def platformGetRegCtx(self, tid):
        ctx = self.archGetRegCtx()
        # NOTE: the tid *is* the port...

        state = STRUCT_X86_THREAD_STATE32()
        scount = ctypes.c_uint32(ctypes.sizeof(state) / 4)
        ret = self.libc.thread_get_state(tid, x86_THREAD_STATE32, addrof(state), addrof(scount));
        if ret != 0:
            raise Exception('thread_get_state (THREAD_STATE32) failed: 0x%.8x' % ret)
        ctx._rctx_Import(state)

        state = STRUCT_X86_DEBUG_STATE32()
        scount = ctypes.c_uint32(ctypes.sizeof(state) / 4)
        ret = self.libc.thread_get_state(tid, x86_DEBUG_STATE32, addrof(state), addrof(scount));
        if ret != 0:
            raise Exception('thread_get_state (DEBUG_STATE32) failed: 0x%.8x' % ret)
        ctx._rctx_Import(state)

        return ctx 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:21,代码来源:darwin.py


注:本文中的ctypes.c_uint32方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。