Replaced exit() with sys.exit()

This commit is contained in:
2021-11-16 11:26:07 -05:00
parent aee22ba779
commit f7ee816c62
+13 -14
View File
@@ -2,7 +2,6 @@
# TODO guarantee numbers in generated passwords # TODO guarantee numbers in generated passwords
# TODO fix syncing for multi-word entries # TODO fix syncing for multi-word entries
# TODO fix folders not being created on server
# TODO combine all print-only functions into one and print based on argument passed to function # TODO combine all print-only functions into one and print based on argument passed to function
# TODO make new, colored list its own callable function # TODO make new, colored list its own callable function
# TODO test /dev/shm security # TODO test /dev/shm security
@@ -11,7 +10,7 @@
from os import environ, remove, system from os import environ, remove, system
from shutil import copy, move, rmtree from shutil import copy, move, rmtree
from sys import argv from sys import argv, exit as s_exit
import random import random
import sshync import sshync
import string import string
@@ -437,7 +436,7 @@ def remove_data(): # deletes an entry or folder from both the client and the se
remove('/dev/shm/sshyp.lock') remove('/dev/shm/sshyp.lock')
except FileNotFoundError: except FileNotFoundError:
print('\nAccess denied.\n') print('\nAccess denied.\n')
exit() s_exit()
if _entry_name.startswith('/'): if _entry_name.startswith('/'):
if _entry_name.replace('/', '', 1).__contains__('/'): if _entry_name.replace('/', '', 1).__contains__('/'):
if device_type == 'c': if device_type == 'c':
@@ -474,7 +473,7 @@ except FileNotFoundError:
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
print("Not all necessary configuration files are present. Please run 'sshyp tweak'!") print("Not all necessary configuration files are present. Please run 'sshyp tweak'!")
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n') print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
exit() s_exit()
# retrieve typed argument # retrieve typed argument
argument = argument_filter() argument = argument_filter()
@@ -488,13 +487,13 @@ elif argument == '':
no_arg() no_arg()
except KeyboardInterrupt: except KeyboardInterrupt:
print('\n') print('\n')
exit() s_exit()
elif argument == 'tweak': elif argument == 'tweak':
try: try:
tweak() tweak()
except KeyboardInterrupt: except KeyboardInterrupt:
print('\n') print('\n')
exit() s_exit()
elif argument == 'help' or argument == '--help' or argument == '-h': elif argument == 'help' or argument == '--help' or argument == '-h':
helper() helper()
elif argument == 'license': elif argument == 'license':
@@ -508,13 +507,13 @@ elif argument == 'add note' or argument == 'add -n' or argument == 'add password
add_entry() add_entry()
except KeyboardInterrupt: except KeyboardInterrupt:
print('\n') print('\n')
exit() s_exit()
elif argument == 'add folder' or argument == 'add -f': elif argument == 'add folder' or argument == 'add -f':
try: try:
add_folder() add_folder()
except KeyboardInterrupt: except KeyboardInterrupt:
print('\n') print('\n')
exit() s_exit()
elif argument == 'edit': elif argument == 'edit':
edit_info() edit_info()
elif argument == 'edit rename' or argument == 'edit relocate' or argument == 'edit -r': elif argument == 'edit rename' or argument == 'edit relocate' or argument == 'edit -r':
@@ -522,20 +521,20 @@ elif argument == 'edit rename' or argument == 'edit relocate' or argument == 'ed
rename() rename()
except KeyboardInterrupt: except KeyboardInterrupt:
print('\n') print('\n')
exit() s_exit()
elif argument == 'edit username' or argument == 'edit -u' or argument == 'edit password' or argument == 'edit -p' or \ elif argument == 'edit username' or argument == 'edit -u' or argument == 'edit password' or argument == 'edit -p' or \
argument == 'edit url' or argument == 'edit -l' or argument == 'edit note' or argument == 'edit -n': argument == 'edit url' or argument == 'edit -l' or argument == 'edit note' or argument == 'edit -n':
try: try:
edit() edit()
except KeyboardInterrupt: except KeyboardInterrupt:
print('\n') print('\n')
exit() s_exit()
elif argument == 'gen' or argument == 'gen update' or argument == 'gen -u': elif argument == 'gen' or argument == 'gen update' or argument == 'gen -u':
try: try:
gen() gen()
except KeyboardInterrupt: except KeyboardInterrupt:
print('\n') print('\n')
exit() s_exit()
elif argument == 'copy': elif argument == 'copy':
copy_info() copy_info()
elif argument == 'copy username' or argument == 'copy -u' or argument == 'copy password' or argument == 'copy -p' or \ elif argument == 'copy username' or argument == 'copy -u' or argument == 'copy password' or argument == 'copy -p' or \
@@ -544,19 +543,19 @@ elif argument == 'copy username' or argument == 'copy -u' or argument == 'copy p
copy_data() copy_data()
except KeyboardInterrupt: except KeyboardInterrupt:
print('\n') print('\n')
exit() s_exit()
elif argument == 'remove' or argument == '-rm': elif argument == 'remove' or argument == '-rm':
try: try:
remove_data() remove_data()
except KeyboardInterrupt: except KeyboardInterrupt:
print('\n') print('\n')
exit() s_exit()
elif argument == 'sync' or argument == '-s': elif argument == 'sync' or argument == '-s':
sync() sync()
else: else:
error = 1 # set error flag to 1 to stop syncing error = 1 # set error flag to 1 to stop syncing
print("\nArgument error! Please run 'sshyp help' for a list of usable commands.\n") print("\nArgument error! Please run 'sshyp help' for a list of usable commands.\n")
exit() s_exit()
# sync at end of program if any changes were made # sync at end of program if any changes were made
if argument != '' and argument != 'help' and argument != '--help' and argument != '-h' and argument != 'license' and \ if argument != '' and argument != 'help' and argument != '--help' and argument != '-h' and argument != 'license' and \