1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-22 22:04:08 +03:00

samba-tool:testparm: Display nicer parameter dump error messages

Now we catch errors for unknown sections or parameters and turn them
into CommandErrors.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14143

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Rowland Penny <rpenny@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Joseph Sutton 2021-04-28 15:46:46 +12:00 committed by Andrew Bartlett
parent 11f26877ce
commit 7d7017b302
2 changed files with 10 additions and 4 deletions

View File

@ -103,9 +103,17 @@ class cmd_testparm(Command):
else:
if section_name is not None or parameter_name is not None:
if parameter_name is None:
lp[section_name].dump(lp.default_service, verbose)
try:
section = lp[section_name]
except KeyError:
raise CommandError("Unknown section %s" % section_name)
else:
section.dump(lp.default_service, verbose)
else:
lp.dump_a_parameter(parameter_name, section_name)
try:
lp.dump_a_parameter(parameter_name, section_name)
except RuntimeError as e:
raise CommandError(e)
else:
if not suppress_prompt:
self.outf.write("Press enter to see a dump of your service definitions\n")

View File

@ -1,2 +0,0 @@
^samba.tests.netcmd.samba.tests.netcmd.TestParmTests.test_no_such_section
^samba.tests.netcmd.samba.tests.netcmd.TestParmTests.test_no_such_parameter