Пример #1
0
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['----']
Пример #2
0
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
Пример #3
0
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
Пример #4
0
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
Пример #5
0
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
Пример #6
0
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)
Пример #7
0
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
Пример #8
0
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
Пример #9
0
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
Пример #10
0
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
Пример #11
0
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
Пример #13
0
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
Пример #14
0
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['----']
Пример #15
0
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)
Пример #16
0
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
Пример #18
0
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
Пример #19
0
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['----']
Пример #20
0
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
Пример #22
0
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
Пример #23
0
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)
Пример #24
0
"""Tools for use in AppleEvent clients and servers:
Пример #25
0
"""Utility routines depending on the finder,
Пример #26
0
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)
Пример #27
0
'''