

def register_undo_command(self, temporary, command):
    'Register a command to be run to undo actions taken.\n\n        .. warning:: This function does not enforce order of operations in terms\n            of file modification vs. command registration.  All undo commands\n            are run first before all normal files are reverted to their previous\n            state.  If you need to maintain strict order, you may create\n            checkpoints before and after the the command registration. This\n            function may be improved in the future based on demand.\n\n        :param bool temporary: Whether the command should be saved in the\n            IN_PROGRESS or TEMPORARY checkpoints.\n        :param command: Command to be run.\n        :type command: list of str\n\n        '
    commands_fp = os.path.join(self._get_cp_dir(temporary), 'COMMANDS')
    command_file = None
    try:
        if os.path.isfile(commands_fp):
            command_file = open(commands_fp, 'ab')
        else:
            command_file = open(commands_fp, 'wb')
        csvwriter = csv.writer(command_file)
        csvwriter.writerow(command)
    except (IOError, OSError):
        logger.error('Unable to register undo command')
        raise errors.ReverterError('Unable to register undo command.')
    finally:
        if (command_file is not None):
            command_file.close()

dataset/ETHPy150Open letsencrypt/letsencrypt/certbot/reverter.py Reverter.register_undo_command/original