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


Python util.find_library方法代码示例

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


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

示例1: __init__

# 需要导入模块: from ctypes import util [as 别名]
# 或者: from ctypes.util import find_library [as 别名]
def __init__(self, ticket_number_key, request_data_key,
                 libcrypto_path=None):
        self.check_des_key(ticket_number_key)
        self.check_des_key(request_data_key)

        self.ticket_number_key = ticket_number_key
        self.request_data_key = request_data_key

        if not libcrypto_path:
            from ctypes.util import find_library
            libcrypto_path = find_library('crypto')
            if not libcrypto_path:
                raise Exception('libcrypto(OpenSSL) not found')

        self.libcrypto = ctypes.CDLL(libcrypto_path)

        if hasattr(self.libcrypto, 'OpenSSL_add_all_ciphers'):
            self.libcrypto.OpenSSL_add_all_ciphers() 
开发者ID:realityone,项目名称:libcet,代码行数:20,代码来源:cet.py

示例2: get_capability

# 需要导入模块: from ctypes import util [as 别名]
# 或者: from ctypes.util import find_library [as 别名]
def get_capability(filename):
    """
        Get names of capabilities and the corresponding capability set for given filename.

            @filename: The complete path to the file
    """
    res = {"capabilities": [], "set": [], "error": False}
    try:
        libcap_path = find_library("cap")
        libcap = ctypes.cdll.LoadLibrary(libcap_path)
    except OSError:
        res["error"] = True
        logging.warning("Unable to find capabilities for {0}".format(filename))
        return res
    cap_t = libcap.cap_get_file(ctypes.create_string_buffer(filename.encode("utf-8")))
    libcap.cap_to_text.restype = ctypes.c_char_p
    cap_object = libcap.cap_to_text(cap_t, None)
    libcap.cap_free(cap_t)
    if cap_object is not None:
        cap_string = cap_object.decode("utf-8")
        res["capabilities"] = (cap_string.split("+")[0])[2:].split(",")
        res["set"] = list(cap_string.split("+")[1])
    return res 
开发者ID:sosy-lab,项目名称:benchexec,代码行数:25,代码来源:util.py

示例3: test_load_library

# 需要导入模块: from ctypes import util [as 别名]
# 或者: from ctypes.util import find_library [as 别名]
def test_load_library(self):
        self.assertIsNotNone(libc_name)
        if is_resource_enabled("printing"):
            print find_library("kernel32")
            print find_library("user32")

        if os.name == "nt":
            windll.kernel32.GetModuleHandleW
            windll["kernel32"].GetModuleHandleW
            windll.LoadLibrary("kernel32").GetModuleHandleW
            WinDLL("kernel32").GetModuleHandleW
        elif os.name == "ce":
            windll.coredll.GetModuleHandleW
            windll["coredll"].GetModuleHandleW
            windll.LoadLibrary("coredll").GetModuleHandleW
            WinDLL("coredll").GetModuleHandleW 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_loading.py

示例4: _load

# 需要导入模块: from ctypes import util [as 别名]
# 或者: from ctypes.util import find_library [as 别名]
def _load(self):
        library_path = find_library(self.name)

        if library_path is None:
            env_var_name = "PATH" if sys.platform == 'win32' else "LD_LIBRARY_PATH"
            raise CannotFindPicoSDKError("PicoSDK (%s) not found, check %s" % (self.name, env_var_name))

        try:
            if sys.platform == 'win32':
                from ctypes import WinDLL
                result = WinDLL(library_path)
            else:
                from ctypes import cdll
                result = cdll.LoadLibrary(library_path)
        except OSError as e:
            raise CannotOpenPicoSDKError("PicoSDK (%s) not compatible (check 32 vs 64-bit): %s" % (self.name, e))
        return result 
开发者ID:picotech,项目名称:picosdk-python-wrappers,代码行数:19,代码来源:library.py

示例5: __init__

# 需要导入模块: from ctypes import util [as 别名]
# 或者: from ctypes.util import find_library [as 别名]
def __init__(self):
        v_posix.PosixMixin.__init__(self)
        v_posix.PtraceMixin.__init__(self)

        self.libc = ctypes.CDLL(c_util.find_library('c'))
        self.myport = self.libc.mach_task_self()

        self.libc.mach_port_allocate.argtypes = [ipc_space_t, mach_port_right_t, ctypes.POINTER(mach_port_name_t)]
        self.libc.mach_port_allocate.restype = kern_return_t

        self.libc.mach_vm_read.argtypes = [ mach_port_t, size_t, size_t, ctypes.POINTER(ctypes.c_void_p), ctypes.POINTER(ctypes.c_uint32)]
        self.libc.mach_vm_read.restype = kern_return_t
        #FIXME mach_port_insert_right

        self.portset = self.newMachPort(MACH_PORT_RIGHT_PORT_SET)
        self.excport = self.newMachRWPort()
        self.addPortToSet(self.excport) 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:19,代码来源:__init__.py

示例6: test_load_library

# 需要导入模块: from ctypes import util [as 别名]
# 或者: from ctypes.util import find_library [as 别名]
def test_load_library(self):
            self.assertFalse(libc_name is None)
            if is_resource_enabled("printing"):
                print find_library("kernel32")
                print find_library("user32")

            if os.name == "nt":
                windll.kernel32.GetModuleHandleW
                windll["kernel32"].GetModuleHandleW
                windll.LoadLibrary("kernel32").GetModuleHandleW
                WinDLL("kernel32").GetModuleHandleW
            elif os.name == "ce":
                windll.coredll.GetModuleHandleW
                windll["coredll"].GetModuleHandleW
                windll.LoadLibrary("coredll").GetModuleHandleW
                WinDLL("coredll").GetModuleHandleW 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:18,代码来源:test_loading.py

示例7: find_yajl_ctypes

# 需要导入模块: from ctypes import util [as 别名]
# 或者: from ctypes.util import find_library [as 别名]
def find_yajl_ctypes(required):
    '''
    Finds and loads yajl shared object of the required major
    version (1, 2, ...) using ctypes.
    '''
    # Importing ``ctypes`` should be in scope of this function to prevent failure
    # of `backends`` package load in a runtime where ``ctypes`` is not available.
    # Example of such environment is Google App Engine (GAE).
    from ctypes import util, cdll

    so_name = util.find_library('yajl')
    if so_name is None:
        raise YAJLImportError('YAJL shared object not found.')
    yajl = cdll.LoadLibrary(so_name)
    require_version(yajl.yajl_version(), required)
    return yajl 
开发者ID:johncsnyder,项目名称:SwiftKitten,代码行数:18,代码来源:__init__.py

示例8: test_load_library

# 需要导入模块: from ctypes import util [as 别名]
# 或者: from ctypes.util import find_library [as 别名]
def test_load_library(self):
        # CRT is no longer directly loadable. See issue23606 for the
        # discussion about alternative approaches.
        #self.assertIsNotNone(libc_name)
        if test.support.verbose:
            print(find_library("kernel32"))
            print(find_library("user32"))

        if os.name == "nt":
            windll.kernel32.GetModuleHandleW
            windll["kernel32"].GetModuleHandleW
            windll.LoadLibrary("kernel32").GetModuleHandleW
            WinDLL("kernel32").GetModuleHandleW
        elif os.name == "ce":
            windll.coredll.GetModuleHandleW
            windll["coredll"].GetModuleHandleW
            windll.LoadLibrary("coredll").GetModuleHandleW
            WinDLL("coredll").GetModuleHandleW 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:20,代码来源:test_loading.py

示例9: test_ctypes

# 需要导入模块: from ctypes import util [as 别名]
# 或者: from ctypes.util import find_library [as 别名]
def test_ctypes(self):
        from ctypes.util import find_library
        libc = ctypes.CDLL(find_library("c"))
        liblog = ctypes.CDLL(find_library("log"))
        self.assertIsNone(find_library("nonexistent"))

        # Work around double-underscore mangling of __android_log_write.
        def assertHasSymbol(dll, name):
            self.assertIsNotNone(getattr(dll, name))
        def assertNotHasSymbol(dll, name):
            with self.assertRaises(AttributeError):
                getattr(dll, name)

        assertHasSymbol(libc, "printf")
        assertHasSymbol(liblog, "__android_log_write")
        assertNotHasSymbol(libc, "__android_log_write")

        # Global search (https://bugs.python.org/issue34592): only works on newer API levels.
        if API_LEVEL >= 21:
            main = ctypes.CDLL(None)
            assertHasSymbol(main, "printf")
            assertHasSymbol(main, "__android_log_write")
            assertNotHasSymbol(main, "nonexistent")

        assertHasSymbol(ctypes.pythonapi, "PyObject_Str") 
开发者ID:chaquo,项目名称:chaquopy,代码行数:27,代码来源:test_android.py

示例10: test_load_library

# 需要导入模块: from ctypes import util [as 别名]
# 或者: from ctypes.util import find_library [as 别名]
def test_load_library(self):
        self.assertIsNotNone(libc_name)
        if test.support.verbose:
            print(find_library("kernel32"))
            print(find_library("user32"))

        if os.name == "nt":
            windll.kernel32.GetModuleHandleW
            windll["kernel32"].GetModuleHandleW
            windll.LoadLibrary("kernel32").GetModuleHandleW
            WinDLL("kernel32").GetModuleHandleW
        elif os.name == "ce":
            windll.coredll.GetModuleHandleW
            windll["coredll"].GetModuleHandleW
            windll.LoadLibrary("coredll").GetModuleHandleW
            WinDLL("coredll").GetModuleHandleW 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:18,代码来源:test_loading.py

示例11: load_libxkb_lookup

# 需要导入模块: from ctypes import util [as 别名]
# 或者: from ctypes.util import find_library [as 别名]
def load_libxkb_lookup() -> LookupFunc:
        import ctypes
        for suffix in ('.0', ''):
            with suppress(Exception):
                lib = ctypes.CDLL('libxkbcommon.so' + suffix)
                break
        else:
            from ctypes.util import find_library
            lname = find_library('xkbcommon')
            if lname is None:
                raise RuntimeError('Failed to find libxkbcommon')
            lib = ctypes.CDLL(lname)

        f = lib.xkb_keysym_from_name
        f.argtypes = [ctypes.c_char_p, ctypes.c_int]
        f.restype = ctypes.c_int

        def xkb_lookup(name: str, case_sensitive: bool = False) -> Optional[int]:
            q = name.encode('utf-8')
            return f(q, int(case_sensitive)) or None

        return xkb_lookup 
开发者ID:kovidgoyal,项目名称:kitty,代码行数:24,代码来源:key_names.py

示例12: psloadlib

# 需要导入模块: from ctypes import util [as 别名]
# 或者: from ctypes.util import find_library [as 别名]
def psloadlib(name):
    """ Loads driver library
    :param name: driver name
    :type name: str
    :returns: ctypes reference to the library
    :rtype: object
    """
    result = None
    try:
        if sys.platform == 'win32':
            result = ctypes.WinDLL(find_library(name))
        else:
            result = cdll.LoadLibrary(find_library(name))
    except OSError as ex:
        print name, "import(%d): Library not found" % sys.exc_info()[-1].tb_lineno
    return result 
开发者ID:picotech,项目名称:picosdk-python-examples,代码行数:18,代码来源:psutils.py

示例13: load_ctypes_library

# 需要导入模块: from ctypes import util [as 别名]
# 或者: from ctypes.util import find_library [as 别名]
def load_ctypes_library(name, signatures, error_checkers):
    """
    Load library ``name`` and return a :class:`ctypes.CDLL` object for it.

    :param str name: the library name
    :param signatures: signatures of methods
    :type signatures: dict of str * (tuple of (list of type) * type)
    :param error_checkers: error checkers for methods
    :type error_checkers: dict of str * ((int * ptr * arglist) -> int)

    The library has errno handling enabled.
    Important functions are given proper signatures and return types to support
    type checking and argument conversion.

    :returns: a loaded library
    :rtype: ctypes.CDLL
    :raises ImportError: if the library is not found
    """
    library_name = find_library(name)
    if not library_name:
        raise ImportError('No library named %s' % name)
    lib = CDLL(library_name, use_errno=True)
    # Add function signatures
    for funcname, signature in signatures.items():
        function = getattr(lib, funcname, None)
        if function:
            argtypes, restype = signature
            function.argtypes = argtypes
            function.restype = restype
            errorchecker = error_checkers.get(funcname)
            if errorchecker:
                function.errcheck = errorchecker
    return lib 
开发者ID:mbusb,项目名称:multibootusb,代码行数:35,代码来源:utils.py

示例14: check_tensorrt_installation

# 需要导入模块: from ctypes import util [as 别名]
# 或者: from ctypes.util import find_library [as 别名]
def check_tensorrt_installation():
    assert find_library('nvinfer') is not None, "Can't find the TensorRT shared library" 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:4,代码来源:common.py

示例15: test_find

# 需要导入模块: from ctypes import util [as 别名]
# 或者: from ctypes.util import find_library [as 别名]
def test_find(self):
        for name in ("c", "m"):
            lib = find_library(name)
            if lib:
                cdll.LoadLibrary(lib)
                CDLL(lib) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_loading.py


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