summaryrefslogtreecommitdiffstats
path: root/firstaidkit
diff options
context:
space:
mode:
authorJoel Andres Granados <jgranado@redhat.com>2008-08-08 10:59:04 +0200
committerJoel Andres Granados <jgranado@redhat.com>2008-08-08 11:29:34 +0200
commit5a0ae1c50be8e9f39478b688da175083cb4ef9f4 (patch)
treec44db7dcb7f1e08821db1f6bef17923791530bb2 /firstaidkit
parent51a175634d24eec42ad5a7cbe23660b42a63470c (diff)
downloadfirstaidkit-5a0ae1c50be8e9f39478b688da175083cb4ef9f4.tar.gz
firstaidkit-5a0ae1c50be8e9f39478b688da175083cb4ef9f4.tar.xz
firstaidkit-5a0ae1c50be8e9f39478b688da175083cb4ef9f4.zip
Add the possibility to pass arguments to plugins.
Given that firstaidkit is fully automated we need a way to modify the plugin behaviour from the initial command. This makes it easy for the plugin developer to get a string with some arguments for his plugin. It is up to the plugin developer to parse the string. The arguments will be accessible through self._args variable.
Diffstat (limited to 'firstaidkit')
-rwxr-xr-xfirstaidkit18
1 files changed, 15 insertions, 3 deletions
diff --git a/firstaidkit b/firstaidkit
index ec864b9..723c640 100755
--- a/firstaidkit
+++ b/firstaidkit
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-import sys, getopt, os, pprint, logging
+import sys, getopt, os, pprint, logging, re
from threading import Thread
from pyfirstaidkit import Tasker
from pyfirstaidkit import Config
@@ -143,6 +143,8 @@ def usage(name):
--list - list all plugins
--info <plugin> - get information about plugin
--nodeps - do not use plugin dependencies
+ --plugin-args=<plugin_name args>
+ - optionally pass arguments to plugin_name
""" % (name, name, name, name, name))
if __name__=="__main__":
@@ -150,7 +152,7 @@ if __name__=="__main__":
params, rest = getopt.getopt(sys.argv[1:], "aftc:r:vl:x:F:g:P:h",
["list", "info=", "auto", "flow", "task", "config=", "root=",
"verbose", "log=", "exclude=","flag=", "gui=", "plugin-path=",
- "print-config", "help", "flags", "nodeps"])
+ "print-config", "help", "flags", "nodeps", "plugin-args="])
except Exception, e:
print("\nError parsing the argument line: ",e,"\n")
usage(sys.argv[0])
@@ -173,7 +175,6 @@ if __name__=="__main__":
elif key in ("-f", "--flow"):
Config.operation.mode = "flow"
Flags.main_help = False
- # Implies nodeps so the individual plugins can run.
Config.operation.dependencies = "False"
elif key in ("-c", "--config"):
@@ -226,6 +227,17 @@ if __name__=="__main__":
elif key in ("--nodeps"):
Config.operation.dependencies = "False"
+ elif key in ("--plugin-args"):
+ m = re.search("[^ ]* ", val)
+ if m:
+ plugin = m.group(0).strip()
+ args = val.strip("%s "%plugin)
+ if plugin and args:
+ if not Config.has_section("plugin-args"):
+ Config.add_section("plugin-args")
+ Config.set("plugin-args", plugin, args)
+
+
if Flags.main_help:
usage(sys.argv[0])
sys.exit(1)