def set_program_profile(self, n, commands,<EOL>program_or_profile='<STR_LIT>',<EOL>timeout=<NUM_LIT:1.0>, max_retries=<NUM_LIT:0>):
<EOL>if program_or_profile != '<STR_LIT>':<EOL><INDENT>current_program = self.get_program(n, timeout=timeout,max_retries=max_retries+<NUM_LIT:2>)<EOL><DEDENT>else:<EOL><INDENT>current_program = None<EOL><DEDENT>stripped_commands = utilities.strip_commands(commands)<EOL>if current_program is not Noneand current_program == stripped_commands:<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>eor = ['<STR_LIT:\n>'] + (['<STR_LIT>'] * (<NUM_LIT:1> + len(stripped_commands)))+ ['<STR_LIT:\n>']<EOL>if program_or_profile != '<STR_LIT>':<EOL><INDENT>header = ['<STR_LIT>'+str(int(n)),<EOL>'<STR_LIT>'+str(int(n))]<EOL><DEDENT>else:<EOL><INDENT>header = ['<STR_LIT>'+str(int(n)),<EOL>'<STR_LIT>'+str(int(n))]<EOL><DEDENT>responses = self.driver.send_commands(header + stripped_commands + ['<STR_LIT>'],timeout=timeout, max_retries=max_retries, eor=eor)<EOL>if not self.driver.command_error(responses[-<NUM_LIT:1>]):<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>if program_or_profile != '<STR_LIT>':<EOL><INDENT>cmds = ['<STR_LIT>', '<STR_LIT>'+str(int(n))]<EOL><DEDENT>else:<EOL><INDENT>cmds = ['<STR_LIT>', '<STR_LIT>'+str(int(n))]<EOL><DEDENT>self.driver.send_commands(cmds, timeout=timeout,<EOL>max_retries=max_retries+<NUM_LIT:2>)<EOL>return False<EOL><DEDENT><DEDENT>
Sets a program/profile on the drive.

        Sets program or profile 'n' on the drive to the sequence of
        commands in 'commands'. If the existing program is identical, it
        is not overwritten (can't check this for a profile). Returns
        whether the program or profile was successfully set or not (if
        the existing one is identical, it is considered a success).

        Parameters
        ----------
        n : int
            Which program to set.
        commands : list or tuple of strings
            ``list`` or ``tuple`` of commands to send to the drive. Each
            command must be a string.
        program_or_profile : {'program', 'profile'}, optional
            Whether to read a program or a profile. Anything other than
            these two values implies the default.
        timeout : number, optional
            Optional timeout in seconds to use when reading the
            response. A negative value or ``None`` indicates that the
            an infinite timeout should be used.
        max_retries : int, optional
            Maximum number of retries to do per command in the case of
            errors.

        Returns
        -------
        success : bool
            Whether the program or profile was successfully set or not
            (an identical program already existing on the drive is
            considered a success).

        Notes
        -----
        'commands' gets wrapped between ['DEL PROGn', 'DEF PROGn'] and
        'END' or the equivalent profile ones.

        See Also
        --------
        get_program : Gets a program.
        run_program_profile : Runs a program or profile.