Bug 9680 - samba-tool: Python exceptions should be caught and prettified.
samba-tool: Python exceptions should be caught and prettified.
Status: NEW
Product: Samba 4.0
Classification: Unclassified
Component: Tools
4.0.3
All Linux
: P5 enhancement
: ---
Assigned To: Andrew Bartlett
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-02-26 03:53 UTC by Michael Mol
Modified: 2014-05-08 23:22 UTC (History)
2 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.