diff options
author | Sol Jerome <sol.jerome@gmail.com> | 2012-08-12 13:31:26 -0500 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2012-08-12 13:31:26 -0500 |
commit | c4c3bee8d74abaa8029c01f68e3a49c739a3bc42 (patch) | |
tree | 58320494ec0dee072351ca3aec834b94758e0ff6 /src/lib | |
parent | c69f8f5743ba76f5d71f38e2b8de0ec0824777c3 (diff) | |
download | bcfg2-c4c3bee8d74abaa8029c01f68e3a49c739a3bc42.tar.gz bcfg2-c4c3bee8d74abaa8029c01f68e3a49c739a3bc42.tar.bz2 bcfg2-c4c3bee8d74abaa8029c01f68e3a49c739a3bc42.zip |
Options: Suppress warnings in bcfg2-admin init
The warning for missing bcfg2.conf is just ugly when trying to
initialize your bcfg2-server via bcfg2-admin init. This commit prevents
us from spamming the new user with irrelevant information.
Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Bcfg2/Options.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/lib/Bcfg2/Options.py b/src/lib/Bcfg2/Options.py index a1684dac9..d437bf868 100644 --- a/src/lib/Bcfg2/Options.py +++ b/src/lib/Bcfg2/Options.py @@ -1,11 +1,12 @@ """Option parsing library for utilities.""" -import re -import os -import sys import copy -import shlex import getopt +import inspect +import os +import re +import shlex +import sys import Bcfg2.Client.Tools # Compatibility imports from Bcfg2.Bcfg2Py3k import ConfigParser @@ -160,8 +161,14 @@ class OptionSet(dict): self.cfp = DefaultConfigParser() if (len(self.cfp.read(self.cfile)) == 0 and ('quiet' not in kwargs or not kwargs['quiet'])): - print("Warning! Unable to read specified configuration file: %s" % - self.cfile) + # suppress warnings if called from bcfg2-admin init + caller = inspect.stack()[-1][1].split('/')[-1] + if caller == 'bcfg2-admin' and len(sys.argv) > 1: + if sys.argv[1] == 'init': + return + else: + print("Warning! Unable to read specified configuration file: %s" % + self.cfile) def buildGetopt(self): return ''.join([opt.buildGetopt() for opt in list(self.values())]) |