本文整理汇总了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
示例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
示例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
示例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
示例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
示例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
示例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
示例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)
示例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
示例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)
示例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)
示例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)