def change_airport_password(ssid, new_password):
    """Sets the password for the specified Airport network to the provided value"""
    password, item = find_airport_password(ssid)

    if password != new_password:
        rc = SECURITY.SecKeychainItemModifyAttributesAndData(
            item,
            None,
            len(new_password),
            new_password
        )

        if rc == -61:
            raise RuntimeError("Unable to update password for Airport network %s: permission denied (rc = %d)" % (ssid, rc))
        elif rc != 0:
            raise RuntimeError("Unable to update password for Airport network %s: rc = %d" % (ssid, rc))
dataset/ETHPy150Open MacSysadmin/pymacadmin/examples/ctypes/airport-update.py/change_airport_password/original