(self, osa_script, unpack_fmt, *args)
return values
Execute script with optional arguments and unpack the return values.

    Be careful to put user-supplied values into args, not osa_script, or
    code injection attacks could occur.

    The unpack_fmt string is a str of single characters which defines each
    expected return value from AppleScript.  Each character can be one of:

      's': unicode string
      'b': boolean
      'i': int

    e.g. a string of 'sb' indicates that AppleScript will be returning 2
    values, first a unicode string, and then a boolean.  You will receive
    native Python types containing the values.

    Args:
      osa_script: str, the script to run
      unpack_fmt: str, format string to use when parsing the return values
      *args: array of arguments to pass in
    Returns:
      list of values as parsed by format string
    Raises:
      AppleScriptError: if an error occured at the AppleScript layer
      Error: if unpack_fmt has invalid format characters
Execute script with optional arguments and unpack the return values.
Execute script with optional arguments and unpack the return values .
def ExecuteAndUnpack(self, osa_script, unpack_fmt, *args):
    """Execute script with optional arguments and unpack the return values.

    Be careful to put user-supplied values into args, not osa_script, or
    code injection attacks could occur.

    The unpack_fmt string is a str of single characters which defines each
    expected return value from AppleScript.  Each character can be one of:

      's': unicode string
      'b': boolean
      'i': int

    e.g. a string of 'sb' indicates that AppleScript will be returning 2
    values, first a unicode string, and then a boolean.  You will receive
    native Python types containing the values.

    Args:
      osa_script: str, the script to run
      unpack_fmt: str, format string to use when parsing the return values
      *args: array of arguments to pass in
    Returns:
      list of values as parsed by format string
    Raises:
      AppleScriptError: if an error occured at the AppleScript layer
      Error: if unpack_fmt has invalid format characters
    """
    ret = self.Execute(osa_script, *args)

    noi = ret.numberOfItems()
    lf = len(unpack_fmt)
    if noi != lf:
      raise AppleScriptError(
          'numberOfItems %d != unpack_fmt len %d' % (noi, lf))

    values = []
    idx = 1

    for f in unpack_fmt:
      d = ret.descriptorAtIndex_(idx)
      if f == 's':  # unicode string
        values.append(unicode(d.stringValue()))
      elif f == 'b':  # bool
        values.append(d.booleanValue())
      elif f == 'i':  # int32
        values.append(d.int32Value())
      else:
        raise Error('unknown unpack_fmt char %s', f)
      idx += 1

    return values
def ExecuteAndUnpack ( self , osa_script , unpack_fmt , * args ) : ret = self . Execute ( osa_script , * args ) noi = ret . numberOfItems ( ) lf = len ( unpack_fmt ) if noi != lf : raise AppleScriptError ( 'numberOfItems %d != unpack_fmt len %d' % ( noi , lf ) ) values = [ ] idx = 1 for f in unpack_fmt : d = ret . descriptorAtIndex_ ( idx ) if f == 's' : # unicode string values . append ( unicode ( d . stringValue ( ) ) ) elif f == 'b' : # bool values . append ( d . booleanValue ( ) ) elif f == 'i' : # int32 values . append ( d . int32Value ( ) ) else : raise Error ( 'unknown unpack_fmt char %s' , f ) idx += 1 return values