diff options
author | Martin Sivak <msivak@redhat.com> | 2007-12-04 16:17:59 +0100 |
---|---|---|
committer | Martin Sivak <msivak@redhat.com> | 2007-12-04 16:17:59 +0100 |
commit | 3746fc3357c9aaf0fdf41c1b8f9e10ac5edcb0fe (patch) | |
tree | c58d8a2d13608fc609bb914b9bb955b964f96a12 | |
parent | a62614a26e4bb0e99421dc4e9a66ff53121ffaac (diff) | |
download | firstaidkit-3746fc3357c9aaf0fdf41c1b8f9e10ac5edcb0fe.tar.gz firstaidkit-3746fc3357c9aaf0fdf41c1b8f9e10ac5edcb0fe.tar.xz firstaidkit-3746fc3357c9aaf0fdf41c1b8f9e10ac5edcb0fe.zip |
Split Tasker and the cli interface (for now) in main.py
-rw-r--r-- | main.py | 20 | ||||
-rw-r--r-- | tasker/__init__.py | 3 | ||||
-rw-r--r-- | tasker/tasker.py | 43 |
3 files changed, 51 insertions, 15 deletions
@@ -17,8 +17,8 @@ import sys import getopt -import tasker.plugins -from tasker.configuration import Config +from tasker import Tasker +from tasker import Config class Flags: print_config = False @@ -37,7 +37,7 @@ def usage(name): -g <gui> - frontend to show results -h - this help --print-config - print resulting config file -""" % (name, name) +""" % (name, name, name) if __name__=="__main__": params, rest = getopt.getopt(sys.argv[1:], "ftc:vl:x:g:P:h", ["flow", "task", "config=", "verbose", "log=", "exclude=", "gui=", "plugin-path=", "print-config", "help"]) @@ -80,17 +80,7 @@ if __name__=="__main__": Config.write(sys.stdout) print 76*"-" - pluginSystem = tasker.plugins.PluginSystem() + singlerun = Tasker(Config) + singlerun.run() - if Config.operation.mode == "auto": - for plugin in pluginSystem.list(): - pluginSystem.autorun(plugin) - elif Config.operation.mode == "flow": - pluginSystem.autorun(Config.operation.plugin, flow = Config.operation.flow) - elif Config.operation.mode == "plugin": - pluginSystem.autorun(Config.operation.plugin) - elif Config.operation.mode == "task": - pass - else: - print "Incorrect task specified\n" diff --git a/tasker/__init__.py b/tasker/__init__.py index 44d6775..d24cd9a 100644 --- a/tasker/__init__.py +++ b/tasker/__init__.py @@ -15,3 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +from tasker import Tasker +from configuration import Config + diff --git a/tasker/tasker.py b/tasker/tasker.py new file mode 100644 index 0000000..d26a9a5 --- /dev/null +++ b/tasker/tasker.py @@ -0,0 +1,43 @@ +# 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. + +from log import Logger +from plugins import PluginSystem + +class Tasker: + """The main interpret of tasks described in Config object""" + + def __init__(self, cfg): + self._config = cfg + + def run(self): + pluginSystem = PluginSystem() + + if self._config.operation.mode == "auto": + for plugin in pluginSystem.list(): + pluginSystem.autorun(plugin) + elif self._config.operation.mode == "flow": + pluginSystem.autorun(self._config.operation.plugin, flow = self._config.operation.flow) + elif self._config.operation.mode == "plugin": + pluginSystem.autorun(self._config.operation.plugin) + elif self._config.operation.mode == "task": + pass + else: + Logger.error("Incorrect task specified") + return False + + return True |