def _update_unenrolled_list(sailthru_client, email, course_url, unenroll):
try:<EOL><INDENT>sailthru_response = sailthru_client.api_get("<STR_LIT:user>", {"<STR_LIT:id>": email, "<STR_LIT>": {"<STR_LIT>": <NUM_LIT:1>}})<EOL>if not sailthru_response.is_ok():<EOL><INDENT>error = sailthru_response.get_error()<EOL>logger.error("<STR_LIT>", error.get_message())<EOL>return not can_retry_sailthru_request(error)<EOL><DEDENT>response_json = sailthru_response.json<EOL>unenroll_list = []<EOL>if response_json and "<STR_LIT>" in response_json and response_json["<STR_LIT>"]and "<STR_LIT>" in response_json["<STR_LIT>"]:<EOL><INDENT>unenroll_list = response_json["<STR_LIT>"]["<STR_LIT>"]<EOL><DEDENT>changed = False<EOL>if unenroll:<EOL><INDENT>if course_url not in unenroll_list:<EOL><INDENT>unenroll_list.append(course_url)<EOL>changed = True<EOL><DEDENT><DEDENT>elif course_url in unenroll_list:<EOL><INDENT>unenroll_list.remove(course_url)<EOL>changed = True<EOL><DEDENT>if changed:<EOL><INDENT>sailthru_response = sailthru_client.api_post(<EOL>'<STR_LIT:user>', {'<STR_LIT:id>': email, '<STR_LIT:key>': '<STR_LIT:email>', '<STR_LIT>': {'<STR_LIT>': unenroll_list}})<EOL>if not sailthru_response.is_ok():<EOL><INDENT>error = sailthru_response.get_error()<EOL>logger.error("<STR_LIT>", error.get_message())<EOL>return not can_retry_sailthru_request(error)<EOL><DEDENT><DEDENT>return True<EOL><DEDENT>except SailthruClientError as exc:<EOL><INDENT>logger.exception("<STR_LIT>", email, text_type(exc))<EOL>return False<EOL><DEDENT>
Maintain a list of courses the user has unenrolled from in the Sailthru user record

    Arguments:
        sailthru_client (object): SailthruClient
        email (str): user's email address
        course_url (str): LMS url for course info page.
        unenroll (boolean): True if unenrolling, False if enrolling

    Returns:
        False if retryable error, else True