ipa-replica-manage: print traceback on unexpected error when in verbose mode

Print the traceback to stdout to maintain backwards compatibility.

https://fedorahosted.org/freeipa/ticket/5380

Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Martin Babinsky
2016-03-10 15:40:53 +01:00
committed by Martin Basti
parent 49be6c8d3c
commit e7e1b8c58e

View File

@@ -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,7 +1645,8 @@ def main():
nolookup=options.nolookup)
try:
main()
options, args = parse_options()
main(options, args)
except KeyboardInterrupt:
sys.exit(1)
except SystemExit as e:
@@ -1657,5 +1657,13 @@ 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)