From 93aeca84ab437777cce5891d06c6f7bbfb0c0d4f Mon Sep 17 00:00:00 2001 From: Martin Sivak Date: Wed, 9 Apr 2008 16:29:56 +0200 Subject: Enhance the configuration system to allow getting configuration bits helping with different packages|plugins Do not print the lines around --print-config, so we can save it directly into correct configuration file --- etc/firstaidkit.conf | 82 ---------------------------------------- etc/firstaidkit/firstaidkit.conf | 82 ++++++++++++++++++++++++++++++++++++++++ firstaidkit | 2 - pyfirstaidkit/configuration.py | 14 ++++++- 4 files changed, 95 insertions(+), 85 deletions(-) delete mode 100644 etc/firstaidkit.conf create mode 100644 etc/firstaidkit/firstaidkit.conf diff --git a/etc/firstaidkit.conf b/etc/firstaidkit.conf deleted file mode 100644 index 72481a2..0000000 --- a/etc/firstaidkit.conf +++ /dev/null @@ -1,82 +0,0 @@ -# -# First Aid Kit configuration file. -# -# This file basically expresses what firstaidkit defaults to. You may uncomment -# lines that you want to change. - - -# -# System: -# -[system] - -# -# root: -# Defines the relative root that firstaidkit will use for the execution of its -# plugins. -#root = /mnt/sysimage - -# -# Operation: -# -[operation] - -# -# flags: -# -#flags = "" - -# -# mode: -# -#mode = - -# -# help: -# -#help= - -# -# gui: -# -#gui= - -# -# verbose: -# -#verbose= - -# -# Log: -# -[log] - -# -# method: -# -#method= - -# -# filename: -# -#filename= - -# -# Paths: -# Will hold all the paths defined by the user that hold plugins. -# -[paths] - -# -# These directories are the possible places where one can find plugin or example -# plugins. Add directories as you see fit. Unless you are developing plugins -# the default values should be enough. -# lib64: -# -#lib64/firstaidkit-plugins = /usr/lib64/firstaidkit-plugins -#lib64/firstaidkit-plugins/examples/plugin_examples = /usr/lib64/firstaidkit-plugins/examples/plugin_examples -# -# -# lib: -#lib/firstaidkit-plugins/examples = /usr/lib/firstaidkit-plugins/examples -#lib/firstaidkit-plugins/examples/plugin_examples = /usr/lib/firstaidkit-plugins/examples/plugin_examples diff --git a/etc/firstaidkit/firstaidkit.conf b/etc/firstaidkit/firstaidkit.conf new file mode 100644 index 0000000..72481a2 --- /dev/null +++ b/etc/firstaidkit/firstaidkit.conf @@ -0,0 +1,82 @@ +# +# First Aid Kit configuration file. +# +# This file basically expresses what firstaidkit defaults to. You may uncomment +# lines that you want to change. + + +# +# System: +# +[system] + +# +# root: +# Defines the relative root that firstaidkit will use for the execution of its +# plugins. +#root = /mnt/sysimage + +# +# Operation: +# +[operation] + +# +# flags: +# +#flags = "" + +# +# mode: +# +#mode = + +# +# help: +# +#help= + +# +# gui: +# +#gui= + +# +# verbose: +# +#verbose= + +# +# Log: +# +[log] + +# +# method: +# +#method= + +# +# filename: +# +#filename= + +# +# Paths: +# Will hold all the paths defined by the user that hold plugins. +# +[paths] + +# +# These directories are the possible places where one can find plugin or example +# plugins. Add directories as you see fit. Unless you are developing plugins +# the default values should be enough. +# lib64: +# +#lib64/firstaidkit-plugins = /usr/lib64/firstaidkit-plugins +#lib64/firstaidkit-plugins/examples/plugin_examples = /usr/lib64/firstaidkit-plugins/examples/plugin_examples +# +# +# lib: +#lib/firstaidkit-plugins/examples = /usr/lib/firstaidkit-plugins/examples +#lib/firstaidkit-plugins/examples/plugin_examples = /usr/lib/firstaidkit-plugins/examples/plugin_examples diff --git a/firstaidkit b/firstaidkit index ed4703f..4da0d94 100755 --- a/firstaidkit +++ b/firstaidkit @@ -187,9 +187,7 @@ if __name__=="__main__": sys.exit(1) if Flags.print_config: - print 76*"-" Config.write(sys.stdout) - print 76*"-" sys.exit(0) Config.lock() diff --git a/pyfirstaidkit/configuration.py b/pyfirstaidkit/configuration.py index 3d222bd..94a3243 100644 --- a/pyfirstaidkit/configuration.py +++ b/pyfirstaidkit/configuration.py @@ -23,7 +23,7 @@ from shlex import shlex if os.environ.has_key("FIRST_AID_KIT_CONF"): cfgfile = os.environ["FIRST_AID_KIT_CONF"].split(":") else: - cfgfile = ["/etc/firstaidkit.conf", os.environ["HOME"]+"/.firstaidkit.conf"] + cfgfile = ["/etc/firstaidkit/firstaidkit.conf", os.environ["HOME"]+"/.firstaidkit.conf"] def createDefaultConfig(config): @@ -46,6 +46,9 @@ def createDefaultConfig(config): else: config.system.root = "/" + # Set the directory containing cfg bits for different services/packages + config.system.configuration = "/etc/firstaidkit" + # # There will be 4 default places where FAK will look for plugins, these 4 names # will be reserved in the configuration. lib{,64}-firstaidkit-{,examples} @@ -123,4 +126,13 @@ Config = FAKConfig() createDefaultConfig(Config) Config.read(cfgfile) +def getConfigBits(name, cfg = Config): + """returns configuration object loaded with bits from designated configuration file/service + + name - service you need info from + cfg - configuration object containing the system.configuration value, to specify, where to look for the service file""" + c = FAKConfig() + c.read(os.path.join(cfg.system.configuration, name)) + c.lock() + return c -- cgit