diff options
| author | Joel Andres Granados <jgranado@redhat.com> | 2008-01-02 14:09:23 +0100 |
|---|---|---|
| committer | Joel Andres Granados <jgranado@redhat.com> | 2008-01-02 14:09:23 +0100 |
| commit | 403519b478ffbe5b433b1fd2fb7babe12c693af2 (patch) | |
| tree | 24fc9074d36dc3e63441ee54957bfe41ac721091 /firstaidkit | |
| parent | 08ee3e0010cc712fde32054fe67a7befb9432193 (diff) | |
Add GPL file, move README and PLUGINS into docs. name the name script firstaidkit.
Diffstat (limited to 'firstaidkit')
| -rwxr-xr-x | firstaidkit | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/firstaidkit b/firstaidkit new file mode 100755 index 0000000..15c7f10 --- /dev/null +++ b/firstaidkit @@ -0,0 +1,124 @@ +#!/usr/bin/python -tt +# First Aid Kit - diagnostic and repair tool for Linux +# Copyright (C) 2007 Martin Sivak <msivak@redhat.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +import sys +import getopt +from threading import Thread +from tasker import Tasker +from tasker import Config +from tasker import reporting + +class Flags: + print_config = False + main_help = False + +class Output(Thread): + def __init__(self, queue, *args, **kwargs): + self._running = True + self._queue = queue + Thread.__init__(self, *args, **kwargs) + + def run(self): + while self._running: + message = self._queue.get() + if message[2]==reporting.END: + self._running = False + continue + print message + +def usage(name): + print """Usage: + %s [params] + %s [params] -f plugin flow + %s [params] -t plugin task + params is none or more items from: + -c <config file> - select different config file + -r <root path> - where is the root directory? + -P <path> - set different plugin path + -v - verbose mode + -l <method> - select different log method + -x <plugin> - exclude plugin from run + -g <gui> - frontend to show results + -h - help + --print-config - print resulting config file +""" % (name, name, name) + +if __name__=="__main__": + params, rest = getopt.getopt(sys.argv[1:], "ftc:r:vl:x:g:P:h", ["flow", "task", "config=", "root=", "verbose", "log=", "exclude=", "gui=", "plugin-path=", "print-config", "help"]) + for key,val in params: + if key in ("-t", "--task"): + Config.operation.mode = "task" + Flags.main_help = False + elif key in ("-f", "--flow"): + Config.operation.mode = "flow" + Flags.main_help = False + elif key in ("-c", "--config"): + Config.read(val) + elif key in ("-v", "--verbose"): + Config.operation.verbose = "True" + elif key in ("-l", "--log"): + Config.log.method = val + elif key in ("-x", "--exclude"): + Config.plugin.disabled = Config.plugin.disabled + ' "%s"' % (val.encode("string-escape")) + print "Excluding plugin %s\n" % (val,) + elif key in ("-r", "--root"): + Config.system.root = val + elif key in ("-g", "--gui"): + Config.operation.gui = val + elif key in ("-P", "--plugin-path"): + Config.plugin.path = val + elif key in ("--print-config"): + Flags.print_config = True + elif key in ("-h", "--help"): + Config.operation.help = "True" + Flags.main_help = True + if Config.operation.mode == "flow": + Config.operation.plugin = rest[0] + if len(rest)<=1: + Config.operation.mode = "plugin" + else: + Config.operation.flow = rest[1] + elif Config.operation.mode == "task": + Config.operation.plugin = rest[0] + Config.operation.task = rest[1] + + if Flags.main_help: + usage(sys.argv[0]) + sys.exit(1) + + if Flags.print_config: + print 76*"-" + Config.write(sys.stdout) + print 76*"-" + + Config.lock() + + + singlerun = Tasker(Config) + + outputThread = Output(singlerun.reporting()) + outputThread.start() + + try: + singlerun.run() + finally: + singlerun.end() + + outputThread.join() + + |
