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


Python MacOS.Error方法代码示例

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


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

示例1: findtemplate

# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import Error [as 别名]
def findtemplate(template=None):
    """Locate the applet template along sys.path"""
    if MacOS.runtimemodel == 'macho':
        return None
    if not template:
        template=TEMPLATE
    for p in sys.path:
        file = os.path.join(p, template)
        try:
            file, d1, d2 = Carbon.File.FSResolveAliasFile(file, 1)
            break
        except (Carbon.File.Error, ValueError):
            continue
    else:
        raise BuildError, "Template %r not found on sys.path" % (template,)
    file = file.as_pathname()
    return file 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:buildtools.py

示例2: is_scriptable

# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import Error [as 别名]
def is_scriptable(application):
    """Return true if the application is scriptable"""
    if os.path.isdir(application):
        plistfile = os.path.join(application, 'Contents', 'Info.plist')
        if not os.path.exists(plistfile):
            return False
        plist = plistlib.Plist.fromFile(plistfile)
        return plist.get('NSAppleScriptEnabled', False)
    # If it is a file test for an aete/aeut resource.
    currf = CurResFile()
    try:
        refno = macresource.open_pathname(application)
    except MacOS.Error:
        return False
    UseResFile(refno)
    n_terminology = Count1Resources('aete') + Count1Resources('aeut') + \
        Count1Resources('scsz') + Count1Resources('osiz')
    CloseResFile(refno)
    UseResFile(currf)
    return n_terminology > 0 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:gensuitemodule.py

示例3: processfile

# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import Error [as 别名]
def processfile(fullname, output=None, basepkgname=None,
        edit_modnames=None, creatorsignature=None, dump=None,
        verbose=None):
    """Ask an application for its terminology and process that"""
    if not is_scriptable(fullname) and verbose:
        print >>verbose, "Warning: app does not seem scriptable: %s" % fullname
    if verbose:
        print >>verbose, "\nASKING FOR aete DICTIONARY IN", repr(fullname)
    try:
        aedescobj, launched = OSATerminology.GetAppTerminology(fullname)
    except MacOS.Error, arg:
        if arg[0] in (-1701, -192): # errAEDescNotFound, resNotFound
            if verbose:
                print >>verbose, "GetAppTerminology failed with errAEDescNotFound/resNotFound, trying manually"
            aedata, sig = getappterminology(fullname, verbose=verbose)
            if not creatorsignature:
                creatorsignature = sig
        else:
            raise 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:21,代码来源:gensuitemodule.py

示例4: _get

# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import Error [as 别名]
def _get(self, _object, asfile=None, _attributes={}):
        """_get: get data from an object
        Required argument: the object
        Keyword argument _attributes: AppleEvent attribute dictionary
        Returns: the data
        """
        _code = 'core'
        _subcode = 'getd'

        _arguments = {'----':_object}
        if asfile:
            _arguments['rtyp'] = mktype(asfile)

        _reply, _arguments, _attributes = self.send(_code, _subcode,
                _arguments, _attributes)
        if 'errn' in _arguments:
            raise Error, decodeerror(_arguments)

        if '----' in _arguments:
            return _arguments['----']
            if asfile:
                item.__class__ = asfile
            return item 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:25,代码来源:aetools.py

示例5: open

# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import Error [as 别名]
def open(self, _object, _attributes={}, **_arguments):
        """open: Open the specified object(s)
        Required argument: list of objects to open
        Keyword argument _attributes: AppleEvent attribute dictionary
        """
        _code = 'aevt'
        _subcode = 'odoc'

        if _arguments: raise TypeError, 'No optional args expected'
        _arguments['----'] = _object


        _reply, _arguments, _attributes = self.send(_code, _subcode,
                _arguments, _attributes)
        if 'errn' in _arguments:
            raise Error, decodeerror(_arguments)
        # XXXX Optionally decode result
        if '----' in _arguments:
            return _arguments['----']
#pass 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:aetools.py

示例6: _mac_ver_lookup

# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import Error [as 别名]
def _mac_ver_lookup(selectors,default=None):

    from gestalt import gestalt
    import MacOS
    l = []
    append = l.append
    for selector in selectors:
        try:
            append(gestalt(selector))
        except (RuntimeError, MacOS.Error):
            append(default)
    return l 
开发者ID:glmcdona,项目名称:meddle,代码行数:14,代码来源:platform.py

示例7: leak

# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import Error [as 别名]
def leak():
    # taken from platform._mac_ver_lookup()
    from gestalt import gestalt
    import MacOS

    try:
        gestalt('sysu')
    except MacOS.Error:
        pass 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_gestalt.py

示例8: main_interactive

# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import Error [as 别名]
def main_interactive(interact=0, basepkgname='StdSuites'):
    if interact:
        # Ask for save-filename for each module
        edit_modnames = None
    else:
        # Use default filenames for each module
        edit_modnames = []
    appsfolder = Carbon.Folder.FSFindFolder(-32765, 'apps', 0)
    filename = EasyDialogs.AskFileForOpen(
        message='Select scriptable application',
        dialogOptionFlags=0x1056,       # allow selection of .app bundles
        defaultLocation=appsfolder)
    if not filename:
        return
    if not is_scriptable(filename):
        if EasyDialogs.AskYesNoCancel(
                "Warning: application does not seem scriptable",
                yes="Continue", default=2, no="") <= 0:
            return
    try:
        processfile(filename, edit_modnames=edit_modnames, basepkgname=basepkgname,
        verbose=sys.stderr)
    except MacOS.Error, arg:
        print "Error getting terminology:", arg
        print "Retry, manually parsing resources"
        processfile_fromresource(filename, edit_modnames=edit_modnames,
            basepkgname=basepkgname, verbose=sys.stderr) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:29,代码来源:gensuitemodule.py

示例9: missed

# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import Error [as 别名]
def missed(ae):
    try:
        desc = ae.AEGetAttributeDesc('miss', 'keyw')
    except AE.Error, msg:
        return None 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:aetools.py

示例10: unpackevent

# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import Error [as 别名]
def unpackevent(ae, formodulename=""):
    parameters = {}
    try:
        dirobj = ae.AEGetParamDesc('----', '****')
    except AE.Error:
        pass
    else:
        parameters['----'] = unpack(dirobj, formodulename)
        del dirobj
    # Workaround for what I feel is a bug in OSX 10.2: 'errn' won't show up in missed...
    try:
        dirobj = ae.AEGetParamDesc('errn', '****')
    except AE.Error:
        pass
    else:
        parameters['errn'] = unpack(dirobj, formodulename)
        del dirobj
    while 1:
        key = missed(ae)
        if not key: break
        parameters[key] = unpack(ae.AEGetParamDesc(key, '****'), formodulename)
    attributes = {}
    for key in aekeywords:
        try:
            desc = ae.AEGetAttributeDesc(key, '****')
        except (AE.Error, MacOS.Error), msg:
            if msg[0] != -1701 and msg[0] != -1704:
                raise
            continue
        attributes[key] = unpack(desc, formodulename) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:32,代码来源:aetools.py

示例11: decodeerror

# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import Error [as 别名]
def decodeerror(arguments):
    """Create the 'best' argument for a raise MacOS.Error"""
    errn = arguments['errn']
    err_a1 = errn
    if 'errs' in arguments:
        err_a2 = arguments['errs']
    else:
        err_a2 = MacOS.GetErrorString(errn)
    if 'erob' in arguments:
        err_a3 = arguments['erob']
    else:
        err_a3 = None

    return (err_a1, err_a2, err_a3) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:16,代码来源:aetools.py

示例12: _start

# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import Error [as 别名]
def _start(self):
        """Start the application, if it is not running yet"""
        try:
            self.send('ascr', 'noop')
        except AE.Error:
            _launch(self.target_signature)
            for i in range(LAUNCH_MAX_WAIT_TIME):
                try:
                    self.send('ascr', 'noop')
                except AE.Error:
                    pass
                else:
                    break
                time.sleep(1) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:16,代码来源:aetools.py


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