~dylanmccall/update-manager/dialogs-refactor

« back to all changes in this revision

Viewing changes to janitor/plugincore/plugins/remove_lilo_plugin.py

  • Committer: Barry Warsaw
  • Date: 2012-06-11 15:08:35 UTC
  • mto: (2446.1.6 py3)
  • mto: This revision was merged to the branch mainline in revision 2454.
  • Revision ID: barry@python.org-20120611150835-lbx9cjwzfjy3y7bw
Re-integrate the Python 3 Computer Janitor refactoring branch for now.  The
code itself lives in ~computer-janitor-hackers/computer-janitor/py3refactor
and will eventually be ripped out of here, but for now, this unblocks other
folks.

Still getting test failures in `bzr bd -S` though.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2009  Canonical, Ltd.
 
2
#
 
3
# This program is free software: you can redistribute it and/or modify it
 
4
# under the terms of the GNU General Public License as published by the Free
 
5
# Software Foundation, version 3 of the License.
 
6
#
 
7
# This program is distributed in the hope that it will be useful, but WITHOUT
 
8
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
9
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 
10
# more details.
 
11
#
 
12
# You should have received a copy of the GNU General Public License along with
 
13
# this program.  If not, see <http://www.gnu.org/licenses/>.
 
14
 
 
15
"""Remove lilo if grub is also installed."""
 
16
 
 
17
from __future__ import absolute_import, print_function, unicode_literals
 
18
 
 
19
__metaclass__ = type
 
20
__all__ = [
 
21
    'RemoveLiloPlugin',
 
22
    ]
 
23
 
 
24
 
 
25
import os
 
26
import logging
 
27
 
 
28
from janitor.plugincore.i18n import setup_gettext
 
29
from janitor.plugincore.core.package_cruft import PackageCruft
 
30
from janitor.plugincore.plugin import Plugin
 
31
 
 
32
_ = setup_gettext()
 
33
 
 
34
 
 
35
class RemoveLiloPlugin(Plugin):
 
36
    """Plugin to remove lilo if grub is also installed."""
 
37
 
 
38
    def __init__(self):
 
39
        self.condition = ['jauntyPostDistUpgradeCache']
 
40
 
 
41
    def get_description(self):
 
42
        return _('Remove lilo since grub is also installed.'
 
43
                 '(See bug #314004 for details.)')
 
44
 
 
45
    def get_cruft(self):
 
46
        if 'lilo' in self.app.apt_cache and 'grub' in self.app.apt_cache:
 
47
            lilo = self.app.apt_cache['lilo']
 
48
            grub = self.app.apt_cache['grub']
 
49
            if lilo.is_installed and grub.is_installed:
 
50
                if not os.path.exists('/etc/lilo.conf'):
 
51
                    yield PackageCruft(lilo, self.description)
 
52
                else:
 
53
                    logging.warning('lilo and grub installed, but '
 
54
                                    'lilo.conf exists')