def OSversion(): """return the version of the system software""" finder = _getfinder() args = {} attrs = {} aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('ver2'), fr=None) args['----'] = aeobj_00 _reply, args, attrs = finder.send("core", "getd", args, attrs) if args.has_key('errn'): raise Error, aetools.decodeerror(args) if args.has_key('----'): return args['----']
def _getlabel(object_alias): """label: Get the label for the object.""" finder = _getfinder() args = {} attrs = {} aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cobj'), form='alis', seld=object_alias, fr=None) aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form='prop', seld=aetypes.Type('labi'), fr=aeobj_00) args['----'] = aeobj_01 _reply, args, attrs = finder.send('core', 'getd', args, attrs) if 'errn' in args: raise Error, aetools.decodeerror(args) if '----' in args: return args['----'] else: return
def _setlabel(object_alias, index): """label: Set the label for the object.""" finder = _getfinder() args = {} attrs = {} _code = 'core' _subcode = 'setd' aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="alis", seld=object_alias, fr=None) aeobj_1 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('labi'), fr=aeobj_0) args['----'] = aeobj_1 args["data"] = index _reply, args, attrs = finder.send(_code, _subcode, args, attrs) if args.has_key('errn'): raise Error, aetools.decodeerror(args) return index
def _geticon(object_alias): """get the icondata for object. Binary data of some sort.""" finder = _getfinder() args = {} attrs = {} aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cobj'), form='alis', seld=object_alias, fr=None) aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form='prop', seld=aetypes.Type('iimg'), fr=aeobj_00) args['----'] = aeobj_01 _reply, args, attrs = finder.send('core', 'getd', args, attrs) if 'errn' in args: raise Error, aetools.decodeerror(args) if '----' in args: return args['----'] else: return
def _processproperty(processname, property): """return the partition size and memory used for processname""" finder = _getfinder() args = {} attrs = {} aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('prcs'), form='name', seld=processname, fr=None) aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form='prop', seld=aetypes.Type(property), fr=aeobj_00) args['----'] = aeobj_01 _reply, args, attrs = finder.send('core', 'getd', args, attrs) if 'errn' in args: raise Error, aetools.decodeerror(args) if '----' in args: return args['----'] else: return
def emptytrash(): """empty the trash""" finder = _getfinder() args = {} attrs = {} args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('trsh'), fr=None) _reply, args, attrs = finder.send("fndr", "empt", args, attrs) if args.has_key('errn'): raise aetools.Error, aetools.decodeerror(args)
def _setcomment(object_alias, comment): finder = _getfinder() args = {} attrs = {} aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cobj'), form='alis', seld=object_alias, fr=None) aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form='prop', seld=aetypes.Type('comt'), fr=aeobj_00) args['----'] = aeobj_01 args['data'] = comment _reply, args, attrs = finder.send('core', 'setd', args, attrs) if 'errn' in args: raise Error, aetools.decodeerror(args) if '----' in args: return args['----'] else: return
def _getwindowview(folder_alias): """get the windowview""" attrs = {} args = {} finder = _getfinder() args = {} attrs = {} aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form='alis', seld=folder_alias, fr=None) aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form='prop', seld=aetypes.Type('cwnd'), fr=aeobj_00) aeobj_02 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form='prop', seld=aetypes.Type('pvew'), fr=aeobj_01) args['----'] = aeobj_02 _reply, args, attrs = finder.send('core', 'getd', args, attrs) if 'errn' in args: raise Error, aetools.decodeerror(args) views = {'iimg': 0, 'pnam': 1, 'lgbu': 2} if '----' in args: return views[args['----'].enum] else: return
def emptytrash(): """empty the trash""" finder = _getfinder() args = {} attrs = {} args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form='prop', seld=aetypes.Type('trsh'), fr=None) _reply, args, attrs = finder.send('fndr', 'empt', args, attrs) if 'errn' in args: raise aetools.Error, aetools.decodeerror(args) return
def _seticon(object_alias, icondata): """set the icondata for object, formatted as produced by _geticon()""" finder = _getfinder() args = {} attrs = {} aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cobj'), form='alis', seld=object_alias, fr=None) aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form='prop', seld=aetypes.Type('iimg'), fr=aeobj_00) args['----'] = aeobj_01 args['data'] = icondata _reply, args, attrs = finder.send('core', 'setd', args, attrs) if 'errn' in args: raise Error, aetools.decodeerror(args) if '----' in args: return args['----'].data else: return
def _getlocation(object_alias): """_getlocation: get the location of the icon for the object.""" finder = _getfinder() args = {} attrs = {} aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form='alis', seld=object_alias, fr=None) aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form='prop', seld=aetypes.Type('posn'), fr=aeobj_00) args['----'] = aeobj_01 _reply, args, attrs = finder.send('core', 'getd', args, attrs) if 'errn' in args: raise Error, aetools.decodeerror(args) if '----' in args: pos = args['----'] return (pos.h, pos.v) else: return
def _setwindowview(folder_alias, view=0): attrs = {} args = {} if view == 1: _v = aetypes.Type('pnam') elif view == 2: _v = aetypes.Type('lgbu') else: _v = aetypes.Type('iimg') finder = _getfinder() aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form='alis', seld=folder_alias, fr=None) aeobj_1 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form='prop', seld=aetypes.Type('cwnd'), fr=aeobj_0) aeobj_2 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form='prop', seld=aetypes.Type('pvew'), fr=aeobj_1) aeobj_3 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form='prop', seld=_v, fr=None) _code = 'core' _subcode = 'setd' args['----'] = aeobj_2 args['data'] = aeobj_3 _reply, args, attrs = finder.send(_code, _subcode, args, attrs) if 'errn' in args: raise Error, aetools.decodeerror(args) return args['----'] if '----' in args else None
def putaway(object): """puth the object away, whereever it came from.""" finder = _getfinder() args = {} attrs = {} args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('cdis'), form='name', seld=object, fr=None) _reply, args, attrs = talker.send('fndr', 'ptwy', args, attrs) if 'errn' in args: raise Error, aetools.decodeerror(args) if '----' in args: return args['----'] else: return
def _getwindowsize(folder_alias): """Set the size of a Finder window for folder to (w, h)""" finder = _getfinder() args = {} attrs = {} aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form="alis", seld=folder_alias, fr=None) aeobj_1 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('cwnd'), fr=aeobj_0) aeobj_2 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('posn'), fr=aeobj_1) args['----'] = aeobj_2 _reply, args, attrs = finder.send('core', 'getd', args, attrs) if 'errn' in args: raise Error, aetools.decodeerror(args) if '----' in args: return args['----']
def closewindow(object): """Close a Finder window for folder, Specify by path.""" finder = _getfinder() object = Carbon.File.FSRef(object) object_alias = object.FSNewAliasMinimal() args = {} attrs = {} _code = 'core' _subcode = 'clos' aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form="alis", seld=object_alias, fr=None) args['----'] = aeobj_0 _reply, args, attrs = finder.send(_code, _subcode, args, attrs) if args.has_key('errn'): raise Error, aetools.decodeerror(args)
def openwindow(object): """Open a Finder window for object, Specify object by name or fsspec.""" finder = _getfinder() object = Carbon.File.FSRef(object) object_alias = object.FSNewAliasMinimal() args = {} attrs = {} _code = 'aevt' _subcode = 'odoc' aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form="alis", seld=object_alias, fr=None) args['----'] = aeobj_0 _reply, args, attrs = finder.send(_code, _subcode, args, attrs) if args.has_key('errn'): raise Error, aetools.decodeerror(args)
def closewindow(object): finder = _getfinder() object = Carbon.File.FSRef(object) object_alias = object.FSNewAliasMinimal() args = {} attrs = {} _code = 'core' _subcode = 'clos' aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form='alis', seld=object_alias, fr=None) args['----'] = aeobj_0 _reply, args, attrs = finder.send(_code, _subcode, args, attrs) if 'errn' in args: raise Error, aetools.decodeerror(args) return
def OSversion(): """return the version of the system software""" finder = _getfinder() args = {} attrs = {} aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form='prop', seld=aetypes.Type('ver2'), fr=None) args['----'] = aeobj_00 _reply, args, attrs = finder.send('core', 'getd', args, attrs) if 'errn' in args: raise Error, aetools.decodeerror(args) if '----' in args: return args['----'] else: return
def putaway(object): """puth the object away, whereever it came from.""" finder = _getfinder() args = {} attrs = {} args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('cdis'), form="name", seld=object, fr=None) _reply, args, attrs = talker.send("fndr", "ptwy", args, attrs) if args.has_key('errn'): raise Error, aetools.decodeerror(args) if args.has_key('----'): return args['----']
def _getwindowposition(folder_alias): """Get the size of a Finder window for folder, Specify by path.""" finder = _getfinder() args = {} attrs = {} aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form="alis", seld=folder_alias, fr=None) aeobj_1 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('cwnd'), fr=aeobj_0) aeobj_2 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('ptsz'), fr=aeobj_1) args['----'] = aeobj_2 _reply, args, attrs = finder.send('core', 'getd', args, attrs) if args.has_key('errn'): raise Error, aetools.decodeerror(args) if args.has_key('----'): return args['----']
def filesharing(): status = -1 finder = _getfinder() args = {} attrs = {} args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form='prop', seld=aetypes.Type('fshr'), fr=None) _reply, args, attrs = finder.send('core', 'getd', args, attrs) if 'errn' in args: raise Error, aetools.decodeerror(args) if '----' in args: if args['----'] == 0: status = -1 else: status = 1 args = {} attrs = {} args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form='prop', seld=aetypes.Type('fsup'), fr=None) _reply, args, attrs = finder.send('core', 'getd', args, attrs) if 'errn' in args: raise Error, aetools.decodeerror(args) if '----' in args: if args['----'] == 1: status = 0 return status
def filesharing(): """return the current status of filesharing and whether it is starting up or not: -1 file sharing is off and not starting up 0 file sharing is off and starting up 1 file sharing is on""" status = -1 finder = _getfinder() # see if it is on args = {} attrs = {} args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('fshr'), fr=None) _reply, args, attrs = finder.send("core", "getd", args, attrs) if args.has_key('errn'): raise Error, aetools.decodeerror(args) if args.has_key('----'): if args['----'] == 0: status = -1 else: status = 1 # is it starting up perchance? args = {} attrs = {} args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('fsup'), fr=None) _reply, args, attrs = finder.send("core", "getd", args, attrs) if args.has_key('errn'): raise Error, aetools.decodeerror(args) if args.has_key('----'): if args['----'] == 1: status = 0 return status
def mkobject(dict): want = dict['want'].type form = dict['form'].enum seld = dict['seld'] fr = dict['from'] if form in ('name', 'indx', 'rang', 'test'): if want == 'text': return aetypes.Text(seld, fr) if want == 'cha ': return aetypes.Character(seld, fr) if want == 'cwor': return aetypes.Word(seld, fr) if want == 'clin': return aetypes.Line(seld, fr) if want == 'cpar': return aetypes.Paragraph(seld, fr) if want == 'cwin': return aetypes.Window(seld, fr) if want == 'docu': return aetypes.Document(seld, fr) if want == 'file': return aetypes.File(seld, fr) if want == 'cins': return aetypes.InsertionPoint(seld, fr) if want == 'prop' and form == 'prop' and aetypes.IsType(seld): return aetypes.Property(seld.type, fr) return aetypes.ObjectSpecifier(want, form, seld, fr)
"""Tools for use in AppleEvent clients and servers:
"""Utility routines depending on the finder,
def location(object, pos = None): """Set the position of a Finder window for folder to pos=(w, h). Specify file by name or fsspec. If pos=None, location will return the current position of the object.""" object = Carbon.File.FSRef(object) object_alias = object.FSNewAliasMinimal() if not pos: return _getlocation(object_alias) return _setlocation(object_alias, pos) def _setlocation(object_alias, (x, y)): """_setlocation: Set the location of the icon for the object.""" finder = _getfinder() args = {} attrs = {} aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form='alis', seld=object_alias, fr=None) aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form='prop', seld=aetypes.Type('posn'), fr=aeobj_00) args['----'] = aeobj_01 args['data'] = [x, y] _reply, args, attrs = finder.send('core', 'setd', args, attrs) if 'errn' in args: raise Error, aetools.decodeerror(args) return (x, y) def _getlocation(object_alias): """_getlocation: get the location of the icon for the object.""" finder = _getfinder() args = {} attrs = {} aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form='alis', seld=object_alias, fr=None)
'''