client: fix script execution

if __name__ == "__main__" should be first instead of try block. We want
execute it only when file was executed as script

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

Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
This commit is contained in:
Martin Basti 2016-10-31 13:13:14 +01:00 committed by Jan Cholasta
parent 1f65c07524
commit 8cbbb53591

View File

@ -257,15 +257,16 @@ def main():
return rval return rval
try:
if __name__ == "__main__": if __name__ == "__main__":
sys.exit(main())
except KeyboardInterrupt:
sys.exit(1)
except RuntimeError as e:
sys.exit(e)
finally:
try: try:
os.remove(client.CCACHE_FILE) sys.exit(main())
except Exception: except KeyboardInterrupt:
pass sys.exit(1)
except RuntimeError as e:
sys.exit(e)
finally:
try:
os.remove(client.CCACHE_FILE)
except Exception:
pass