示例#1
0
    def handle_failure(self):
        """Handles our failure cases.

        Args:
            None.

        Returns:
            None.

        """
        msg = ('Failed during vim setup. Do you wish to '
               'roll back the changes? [y/n]')
        generic_msg.prompt(msg)
        input_result = raw_input().lower()
        if input_result in self.yes_answers:
            msg = ('Rolling back changes.')
            generic_msg.info(msg)
            rmdir_result = handle_rmdir(self.vim_dir, recursive=True)
            if not rmdir_result:
                msg = ('There was an issue removing the .vim directory.')
                generic_msg.error(msg)
            else:
                msg = ('Moving the backup directory %s back '
                       'to .vim.' % (self.backup_directory))
                generic_msg.info(msg)
                handle_moving_dirs(self.backup_directory, self.vim_dir)
        else:
            msg = ('Not rolling back. VIM setup may be '
                   'incomplete. Your backup can be found '
                   'here: %s' % (self.backup_directory))
            generic_msg.warning(msg)

        exit_msg = ('Failed to do the setup properly. My apologies.')
        sys.exit(exit_msg)
示例#2
0
    def backup_vimdir(self):
        """Backs up the .vim directory

        Args:
            None.

        Returns:
            bool. True or False

        """
        msg = ('Backing up your vim directory...')
        generic_msg.info(msg)
        self.backup_directory = os.path.join(self.home_dir, '.vim_backup')
        if os.path.exists(self.backup_directory):
            msg = ('It appears that the directory already exists. Would you '
                   'like to backup the older directory with the current '
                   'datetime appended to it? [y/n]')
            generic_msg.prompt(msg)
            input_result = raw_input().lower()
            if input_result in self.yes_answers:
                cur_date = datetime.now().strftime('%Y_%M_%d_%H_%M_%S')
                self.backup_directory = os.path.join(
                    self.home_dir, '.vim_backup_%s' % (cur_date)
                )
            else:
                msg = ('User cancelled vim setup.')
                generic_msg.info(msg)
                sys.exit(1)

        result = handle_moving_dirs(self.vim_dir, self.backup_directory)
        return result
示例#3
0
    def vim_setup(self):
        """This does all of our setup to grab all the necessary data.

        Args:
            None.

        Returns:
            bool. True or False.

        """
        pathogen_dirs = ['autoload', 'bundle',
                         'colors', 'plugin']

        vimdir_result = handle_mkdir(self.vim_dir)
        if not vimdir_result['success']:
            generic_msg.error(vimdir_result['msg'])
            self.handle_failure()

        msg = ('Making the following '
               'directories: %s' % (', '.join(pathogen_dirs)))
        generic_msg.info(msg)
        for dirname in pathogen_dirs:
            full_dirname = os.path.join(self.vim_dir, dirname)
            dir_result = handle_mkdir(full_dirname)
            if not dir_result['success']:
                generic_msg.error(dir_result['msg'])
                self.handle_failure()

        plugin_result = self.get_plugins()
        if not plugin_result:
            msg = ('Something really f****d up here. We have to '
                   'kill this now.')
            generic_msg.error(msg)
            self.handle_failure()

        msg = ('We can run some cleanup and try and remove all of the '
               '.rst, .md and .markdown files now if you would like. '
               'Proceed? [y/n]')
        generic_msg.prompt(msg)
        input_result = raw_input().lower()
        if input_result in self.yes_answers:
            cleanup_result = self.handle_cleanup()
            if cleanup_result:
                msg = ('Something during the cleanup process got borked. '
                       'Not a big deal, but you should probably check '
                       'it out.')
                generic_msg.warning(msg)

        return True