summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-06-20 13:51:39 +0200
committerJelmer Vernooij <jelmer@samba.org>2010-06-20 13:51:39 +0200
commit08a3e8b9f4d4d99cfca65752b0b516e0ec3f8651 (patch)
tree651c408c337cf8204de96f8ca69024f6d6cfac92 /source4/scripting
parent338315f4d713e2648419f2eda805748901435204 (diff)
downloadsamba-08a3e8b9f4d4d99cfca65752b0b516e0ec3f8651.tar.gz
samba-08a3e8b9f4d4d99cfca65752b0b516e0ec3f8651.tar.bz2
samba-08a3e8b9f4d4d99cfca65752b0b516e0ec3f8651.zip
testparm: Simplify default option handling.
Diffstat (limited to 'source4/scripting')
-rwxr-xr-xsource4/scripting/bin/testparm33
1 files changed, 14 insertions, 19 deletions
diff --git a/source4/scripting/bin/testparm b/source4/scripting/bin/testparm
index 98f0c19a5e..95adcf3f16 100755
--- a/source4/scripting/bin/testparm
+++ b/source4/scripting/bin/testparm
@@ -101,16 +101,6 @@ def do_share_checks(lp, logger):
valid = False
return valid
-def dump(lp, section_name=None, parameter_name=None, show_defaults=False):
- if section_name is not None or parameter_name is not None:
- if parameter_name is None:
- lp[section_name].dump(sys.stdout, lp.default_service, show_defaults)
- else:
- print lp.get(parameter_name, section_name)
- else:
- lp.dump(sys.stdout, show_defaults)
-
-
def check_client_access(lp, cname, caddr):
# this is totally ugly, a real `quick' hack
for s in lp.services():
@@ -133,17 +123,17 @@ if __name__ == '__main__':
help="Client DNS name for 'hosts allow' checking (should match reverse lookup)")
parser.add_option("--client-ip", type="string", metavar="IP",
help="Client IP address for 'hosts allow' checking")
- parser.add_option("--suppress-prompt", action="store_true",
+ parser.add_option("--suppress-prompt", action="store_true", default=False,
help="Suppress prompt for enter")
parser.add_option("--verbose", action="store_true",
- help="Show default options too")
+ default=False, help="Show default options too")
parser.add_option_group(options.VersionOptions(parser))
# We need support for smb.conf macros before this will work again
parser.add_option("--server", type="string",
help="Set %%L macro to servername")
# These are harder to do with the new code structure
- parser.add_option("--show-all-parameters", action="store_true",
- help="Show the parameters, type, possible values")
+ parser.add_option("--show-all-parameters", action="store_true",
+ default=False, help="Show the parameters, type, possible values")
sambaopts = options.SambaOptions(parser)
parser.add_option_group(sambaopts)
@@ -191,11 +181,16 @@ if __name__ == '__main__':
if cname is not None:
check_client_access(lp, cname, caddr)
else:
- if not opts.suppress_prompt:
- print "Press enter to see a dump of your service definitions\n"
- sys.stdin.readline()
- dump(lp, opts.section_name, opts.parameter_name, opts.verbose or False)
-
+ if opts.section_name is not None or opts.parameter_name is not None:
+ if opts.parameter_name is None:
+ lp[opts.section_name].dump(sys.stdout, lp.default_service, opts.verbose)
+ else:
+ print lp.get(opts.parameter_name, opts.section_name)
+ else:
+ if not opts.suppress_prompt:
+ print "Press enter to see a dump of your service definitions\n"
+ sys.stdin.readline()
+ lp.dump(sys.stdout, opts.verbose)
if valid:
sys.exit(0)
else: