2
# -*- coding: utf-8 -*-
4
# (c) Copyright 2011-2014 Hewlett-Packard Development Company, L.P.
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
# Author: Amarnath Chitumalla
24
__title__ = 'HPLIP Uninstaller'
25
__mod__ = 'hp-uninstall'
26
__doc__ = "Uninstaller for HPLIP ."
29
import getopt, os, sys, re, time
33
from base import utils, tui
34
from installer.core_install import *
37
USAGE = [(__doc__, "", "name", True),
38
("Usage: %s [OPTIONS]" % __mod__, "", "summary", True),
41
utils.USAGE_LOGGING1, utils.USAGE_LOGGING2, utils.USAGE_LOGGING3,
42
("Non-interactive mode:", "-n (without asking for permission)","option",False),
47
def usage(typ='text'):
49
utils.log_title(__title__, __version__)
51
utils.format_text(USAGE, typ, __title__, __mod__, __version__)
54
mode = INTERACTIVE_MODE
60
log.set_module(__mod__)
64
opts, args = getopt.getopt(sys.argv[1:], 'hl:gn',
65
['help', 'help-rest', 'help-man', 'help-desc', 'gui', 'lang=','logging=', 'debug'])
67
except getopt.GetoptError, e:
72
if os.getenv("HPLIP_DEBUG"):
73
log.set_level('debug')
76
if o in ('-h', '--help'):
79
elif o == '--help-rest':
82
elif o == '--help-man':
85
elif o in ('-q', '--lang'):
88
elif o == '--help-desc':
92
elif o in ('-l', '--logging'):
93
log_level = a.lower().strip()
94
# if not log.set_level(log_level):
97
elif o in ('-g', '--debug'):
99
# log.set_level('debug')
102
mode = NON_INTERACTIVE_MODE
105
if log_level is not None:
106
if not log.set_level(log_level):
109
log_file = os.path.normpath('/var/log/hp/hplip-uninstall.log')
111
log.error("To run 'hp-uninstall' utility, you must have root privileges.(Try using 'sudo' or 'su -c')")
114
if os.path.exists(log_file):
117
log.set_logfile(log_file)
118
log.set_where(log.LOG_TO_CONSOLE_AND_FILE)
120
log.debug("Log file=%s" % log_file)
121
log.debug("euid = %d" % os.geteuid())
123
utils.log_title(__title__, __version__, True)
125
log.info("Uninstaller log saved in: %s" % log.bold(log_file))
128
core = CoreInstall(MODE_CHECK, INTERACTIVE_MODE)