Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(7)  |  Call(5)  |  Derive(0)  |  Import(2)
Load a Carbon framework using ctypes.CDLL and add an errcheck wrapper to
replace traditional errno-style error checks with exception handling.

Example:
>>> load_carbon_framework('/System/Library/Frameworks/Security.framework/Versions/Current/Security') # doctest: +ELLIPSIS
<CDLL '/System/Library/Frameworks/Security.framework/Versions/Current/Security', handle ... at ...>

        def load_carbon_framework(f_path):
    """
    Load a Carbon framework using ctypes.CDLL and add an errcheck wrapper to
    replace traditional errno-style error checks with exception handling.

    Example:
    >>> load_carbon_framework('/System/Library/Frameworks/Security.framework/Versions/Current/Security') # doctest: +ELLIPSIS
    
    """
    framework = ctypes.cdll.LoadLibrary(f_path)

    # TODO: Do we ever need to wrap framework.__getattr__ too?
    old_getitem = framework.__getitem__
    @wraps(old_getitem)
    def new_getitem(k):
        v = old_getitem(k)
        if hasattr(v, "errcheck") and not v.errcheck:
            v.errcheck = carbon_errcheck
        return v
    framework.__getitem__ = new_getitem

    return framework
        


src/p/y/PyMacAdmin-1.0/bin/delete-certificate.py   PyMacAdmin(Download)
#!/usr/bin/env python2.5
 
from PyMacAdmin import carbon_call, load_carbon_framework
from PyMacAdmin.Security import kSecCertificateItemClass
from PyMacAdmin.Security.Keychain import SecKeychainAttribute, SecKeychainAttributeList
from CoreFoundation import CFRelease
 
Security = load_carbon_framework('/System/Library/Frameworks/Security.framework/Versions/Current/Security')
 
label    = "<some label text here>"

src/p/y/pymacadmin-HEAD/bin/delete-certificate.py   pymacadmin(Download)
#!/usr/bin/env python2.5
 
from PyMacAdmin import carbon_call, load_carbon_framework
from PyMacAdmin.Security import kSecCertificateItemClass
from PyMacAdmin.Security.Keychain import SecKeychainAttribute, SecKeychainAttributeList
from CoreFoundation import CFRelease
 
Security = load_carbon_framework('/System/Library/Frameworks/Security.framework/Versions/Current/Security')
 
label    = "<some label text here>"

src/p/y/PyMacAdmin-1.0/lib/PyMacAdmin/Security/__init__.py   PyMacAdmin(Download)
# Security framework we use a single copy hanging of this module so everything
# else can simply use Security.lib.SecKeychainFoo(…)
lib = PyMacAdmin.load_carbon_framework('/System/Library/Frameworks/Security.framework/Versions/Current/Security')
 
CSSM_DB_RECORDTYPE_APP_DEFINED_START = 0x80000000

src/p/y/pymacadmin-HEAD/lib/PyMacAdmin/Security/__init__.py   pymacadmin(Download)
# Security framework we use a single copy hanging of this module so everything
# else can simply use Security.lib.SecKeychainFoo(…)
lib = PyMacAdmin.load_carbon_framework('/System/Library/Frameworks/Security.framework/Versions/Current/Security')
 
CSSM_DB_RECORDTYPE_APP_DEFINED_START = 0x80000000

src/l/u/LuggagePackages-HEAD/CrankdInstaller/PyMacAdmin/Security/__init__.py   LuggagePackages(Download)
# Security framework we use a single copy hanging of this module so everything
# else can simply use Security.lib.SecKeychainFoo(…)
lib = PyMacAdmin.load_carbon_framework('/System/Library/Frameworks/Security.framework/Versions/Current/Security')
 
CSSM_DB_RECORDTYPE_APP_DEFINED_START = 0x80000000