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 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() 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 _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 _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 args.has_key('errn'): raise Error, aetools.decodeerror(args) views = {'iimg': 0, 'pnam': 1, 'lgbu': 2} if args.has_key('----'): return views[args['----'].enum]
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 'errn' in args: raise Error, aetools.decodeerror(args) if '----' in args: return args['----'] else: return
def processes(): """processes returns a list of all active processes running on this computer and their creators.""" finder = _getfinder() args = {} attrs = {} processnames = [] processnumbers = [] creators = [] partitions = [] used = [] ## get the processnames or else the processnumbers args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('prcs'), form="indx", seld=aetypes.Unknown( 'abso', "all "), fr=None) _reply, args, attrs = finder.send('core', 'getd', args, attrs) if args.has_key('errn'): raise Error, aetools.decodeerror(args) p = [] if args.has_key('----'): p = args['----'] for proc in p: if hasattr(proc, 'seld'): # it has a real name processnames.append(proc.seld) elif hasattr(proc, 'type'): if proc.type == "psn ": # it has a process number processnumbers.append(proc.data) ## get the creators args = {} attrs = {} aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('prcs'), form="indx", seld=aetypes.Unknown('abso', "all "), fr=None) args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('fcrt'), fr=aeobj_0) _reply, args, attrs = finder.send('core', 'getd', args, attrs) if args.has_key('errn'): raise Error, aetools.decodeerror(_arg) if args.has_key('----'): p = args['----'] creators = p[:] ## concatenate in one dict result = [] if len(processnames) > len(processnumbers): data = processnames else: data = processnumbers for i in range(len(creators)): result.append((data[i], creators[i])) return result
def OSversion(): 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) return args['----'] if '----' in args else None
def _setwindowview(folder_alias, view = 0): """set the windowview""" 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) if '----' in args: return args['----'] else: return
def _geticon(object_alias): 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) return args['----'] if '----' in args else None
def _processproperty(processname, property): 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) return args['----'] if '----' in args else None
def processes(): """processes returns a list of all active processes running on this computer and their creators.""" finder = _getfinder() args = {} attrs = {} processnames = [] processnumbers = [] creators = [] partitions = [] used = [] args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('prcs'), form='indx', seld=aetypes.Unknown( 'abso', 'all '), fr=None) _reply, args, attrs = finder.send('core', 'getd', args, attrs) if 'errn' in args: raise Error, aetools.decodeerror(args) p = [] if '----' in args: p = args['----'] for proc in p: if hasattr(proc, 'seld'): processnames.append(proc.seld) elif hasattr(proc, 'type'): if proc.type == 'psn ': processnumbers.append(proc.data) args = {} attrs = {} aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('prcs'), form='indx', seld=aetypes.Unknown('abso', 'all '), fr=None) args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form='prop', seld=aetypes.Type('fcrt'), fr=aeobj_0) _reply, args, attrs = finder.send('core', 'getd', args, attrs) if 'errn' in args: raise Error, aetools.decodeerror(_arg) if '----' in args: p = args['----'] creators = p[:] result = [] if len(processnames) > len(processnumbers): data = processnames else: data = processnumbers for i in range(len(creators)): result.append((data[i], creators[i])) return result
def _getcomment(object_alias): 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 _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 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 _getwindowsize(folder_alias): 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) return args['----'] if '----' in args else None
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 _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['----']
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 args.has_key('errn'): raise Error, aetools.decodeerror(args) if args.has_key('----'): return 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['----']
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 _setlabel(object_alias, index): 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 'errn' in args: raise Error, aetools.decodeerror(args) return index
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 args.has_key('errn'): raise Error, aetools.decodeerror(args) if args.has_key('----'): pos = args['----'] return pos.h, pos.v
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 args.has_key('errn'): raise Error, aetools.decodeerror(args) if args.has_key('----'): return args['----']
def _getlocation(object_alias): 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 _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 _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 args.has_key('errn'): raise Error, aetools.decodeerror(args) if args.has_key('----'): return args['----'].data
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 _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 args.has_key('errn'): raise Error, aetools.decodeerror(args) if args.has_key('----'): return args['----']
def putaway(object): 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) 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 args.has_key('errn'): raise Error, aetools.decodeerror(args) if args.has_key('----'): 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)