Use sys.exit() instead of exit():

exit() cuases stack trace output from pyinstaller exe.
	It is also recommended to use sys.exit() in prodcution.

Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
HeshamTB 2020-08-28 18:53:55 +03:00
parent b7597320fd
commit d51a42589c
Signed by: Hesham
GPG Key ID: 74876157D199B09E

16
rsa.py
View File

@ -40,11 +40,11 @@ def main():
saveKeyFile(key, keyFileName) saveKeyFile(key, keyFileName)
except IOError: except IOError:
print("could not write file") print("could not write file")
exit(1) sys.exit(1)
except Exception as ex: except Exception as ex:
print(ex) print(ex)
exit(1) sys.exit(1)
exit(0) sys.exit(0)
if sys.argv[1] == "encrypt": ##rsa encrypt <message> <key> <signer> if sys.argv[1] == "encrypt": ##rsa encrypt <message> <key> <signer>
if len(sys.argv) == 5: if len(sys.argv) == 5:
msg = sys.argv[2] msg = sys.argv[2]
@ -64,7 +64,7 @@ def main():
print("Not enough arguments") print("Not enough arguments")
print("rsa encrypt <message> <key> <signer>") print("rsa encrypt <message> <key> <signer>")
#Make help function #Make help function
exit(0) sys.exit(0)
if sys.argv[1] == "decrypt": ##rsa decrypt "<cipher>" <key> if sys.argv[1] == "decrypt": ##rsa decrypt "<cipher>" <key>
if len(sys.argv) == 4: if len(sys.argv) == 4:
cipher = sys.argv[2] cipher = sys.argv[2]
@ -83,16 +83,16 @@ def main():
else: else:
print("Not enough arguments") print("Not enough arguments")
print("rsa decrypt \"<cipher>\" <keyid>") print("rsa decrypt \"<cipher>\" <keyid>")
exit(0) sys.exit(0)
if sys.argv[1] == "list": if sys.argv[1] == "list":
listKeys() listKeys()
exit(0) sys.exit(0)
if sys.argv[1] == "export": #rsa export <key> if sys.argv[1] == "export": #rsa export <key>
if len(sys.argv) == 3: if len(sys.argv) == 3:
key_file_name = sys.argv[2] key_file_name = sys.argv[2]
exportKey(key_file_name) exportKey(key_file_name)
exit(0) sys.exit(0)
else: else:
print("Not enough arguments") print("Not enough arguments")
print("rsa export <keyid>") print("rsa export <keyid>")
@ -107,7 +107,7 @@ def main():
#No command exit code #No command exit code
printHelp() printHelp()
exit(127) sys.exit(127)