Bug 9680 - samba-tool: Python exceptions should be caught and prettified.
Summary: samba-tool: Python exceptions should be caught and prettified.
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.0
Classification: Unclassified
Component: Tools (show other bugs)
Version: 4.0.3
Hardware: All Linux
: P5 enhancement (vote)
Target Milestone: ---
Assignee: Andrew Bartlett
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-26 03:53 UTC by Michael Mol
Modified: 2022-09-13 23:35 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Mol 2013-02-26 03:53:30 UTC
Python exceptions should be caught and prettified.

For example:

$ samba-tool dns zonelist kaylee
Password for [administrator@FIREFLY.MICHAEL.MOL.NAME]:
Failed to bind to uuid 50abc2a4-574d-40b3-9d66-ee4fd5fba076 for 50abc2a4-574d-40b3-9d66-ee4fd5fba076@ncacn_ip_tcp:kaylee[1024,sign] NT_STATUS_IO_TIMEOUT
ERROR(runtime): uncaught exception - (-1073741643, 'NT_STATUS_IO_TIMEOUT')
  File "/usr/lib64/python2.7/site-packages/samba/netcmd/__init__.py", line 175, in _run
    return self.run(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/samba/netcmd/dns.py", line 804, in run
    dns_conn = dns_connect(server, self.lp, self.creds)
  File "/usr/lib64/python2.7/site-packages/samba/netcmd/dns.py", line 37, in dns_connect
    dns_conn = dnsserver.dnsserver(binding_str, lp, creds)


While I can spot what happened (I took too long to enter my password, leading to a timeout), it requires spotting the NT_STATUS_IO_TIMEOUT inside a wall of text.

Better output would be:

$ samba-tool dns zonelist kaylee
Password for [administrator@FIREFLY.MICHAEL.MOL.NAME]:
Failed to bind to uuid 50abc2a4-574d-40b3-9d66-ee4fd5fba076 for 50abc2a4-574d-40b3-9d66-ee4fd5fba076@ncacn_ip_tcp:kaylee[1024,sign] NT_STATUS_IO_TIMEOUT

Protocol timed out.

(The key difference being the descriptor string "Protocol timed out." instead of  the exception stack.)
Comment 1 Matthias Dieter Wallnöfer 2014-04-24 19:35:40 UTC
I think that this is an ENHANCEMENT.

Jelmer, do you have any further opinion on this one?
Comment 2 Jelmer Vernooij 2014-04-24 21:51:38 UTC
(In reply to comment #1)
> I think that this is an ENHANCEMENT.
> 
> Jelmer, do you have any further opinion on this one?

We have infrastructure to display exceptions as regular user errors.

In this particular case, it's an internal exception that's caught and so we print a backtrace.

The correct fix here is to catch this exception and throw a CommandError instead.
Comment 3 Douglas Bagnall 2022-09-13 23:35:11 UTC
This example would have been improved with commit
5701b99b5c134ee6ffffa0f34c2797c9c814d280.

Now you'll only see something like:

Connecting to DNS RPC server kaylee failed with (-1073741643, 'NT_STATUS_IO_TIMEOUT')

which is *somewhat* better.