On 03/14/2016 06:26 PM, Martin Basti wrote:



On 10.03.2016 15:59, Martin Babinsky wrote:
https://fedorahosted.org/freeipa/ticket/5380



NACK

1)
Maybe we should print traceback in verbose mode for RuntimeError as well.

2)
IMO would be better to print traceback first and then, print error

Martin^2

Attaching updated patch.

--
Martin^3 Babinsky
From ee02b2ad2e0cb2f37f7267aadbbadc1ff39a7b7a Mon Sep 17 00:00:00 2001
From: Martin Babinsky <mbabi...@redhat.com>
Date: Thu, 10 Mar 2016 15:40:53 +0100
Subject: [PATCH] ipa-replica-manage: print traceback on unexpected error when
 in verbose mode

Also print traceback when RuntimeError is raised. Print it to stdout to
maintain backwards compatibility.

https://fedorahosted.org/freeipa/ticket/5380
---
 install/tools/ipa-replica-manage | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/install/tools/ipa-replica-manage b/install/tools/ipa-replica-manage
index 0497a0f0549b392216c654ab67d98cedbf122a4b..e4f8d902b9e827c87c009c3d39f168328e1c155f 100755
--- a/install/tools/ipa-replica-manage
+++ b/install/tools/ipa-replica-manage
@@ -27,6 +27,7 @@ import re
 import ldap
 import socket
 import time
+import traceback
 
 from six.moves.urllib.parse import urlparse
 
@@ -1529,14 +1530,12 @@ def exit_on_managed_topology(what):
              "Please use `ipa topologysegment-*` commands to manage "
              "the topology.".format(what))
 
-def main():
+def main(options, args):
     if os.getegid() == 0:
         installutils.check_server_configuration()
     elif not os.path.exists(paths.IPA_DEFAULT_CONF):
         sys.exit("IPA is not configured on this system.")
 
-    options, args = parse_options()
-
     # Just initialize the environment. This is so the installer can have
     # access to the plugin environment
     api_env = {'in_server' : True,
@@ -1646,16 +1645,23 @@ def main():
                       nolookup=options.nolookup)
 
 try:
-    main()
+    options, args = parse_options()
+    main(options, args)
 except KeyboardInterrupt:
     sys.exit(1)
 except SystemExit as e:
     sys.exit(e)
-except RuntimeError as e:
-    sys.exit(e)
 except socket.timeout:
     print("Connection timed out.")
     sys.exit(1)
 except Exception as e:
-    print("unexpected error: %s" % str(e))
+    if options.verbose:
+        traceback.print_exc(file=sys.stdout)
+    else:
+        print(
+            "Re-run {} with --verbose option to get more information".format(
+                sys.argv[0])
+        )
+
+    print("Unexpected error: %s" % str(e))
     sys.exit(1)
-- 
2.5.0

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to