mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-08-28 12:56:28 -04:00
Error messages are now more consistent and informative
This commit is contained in:
@@ -307,7 +307,7 @@ def no_arg(): # displays a list of entries and gives an option to select one fo
|
||||
_output = Popen(f"{gpg} -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{_read_entry.replace('/', '', 1)}.gpg'", shell=True, stdout=PIPE, stderr=STDOUT, close_fds=True)
|
||||
_block = _output.communicate()[0].strip() # blocks the program from proceeding until stdout is given
|
||||
if _output.returncode == 2:
|
||||
print(f"\nError: entry ({_read_entry.replace('/', '', 1)}) does not exist\n")
|
||||
print(f"\n\u001b[38;5;1mError: entry ({_read_entry.replace('/', '', 1)}) does not exist\u001b[0m\n")
|
||||
s_exit(1)
|
||||
entry_reader(f"{tmp_dir}{_shm_folder}/{_shm_entry}")
|
||||
rmtree(f"{tmp_dir}{_shm_folder}")
|
||||
@@ -318,7 +318,7 @@ def read_shortcut(): # shortcut to quickly read an entry
|
||||
_output = Popen(f"{gpg} -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{argument.replace('/', '', 1)}.gpg'", shell=True, stdout=PIPE, stderr=STDOUT, close_fds=True)
|
||||
_block = _output.communicate()[0].strip() # blocks the program from proceeding until stdout is given
|
||||
if _output.returncode == 2:
|
||||
print(f"\nError: entry ({argument.replace('/', '', 1)}) does not exist\n")
|
||||
print(f"\n\u001b[38;5;1mError: entry ({argument.replace('/', '', 1)}) does not exist\u001b[0m\n")
|
||||
s_exit(1)
|
||||
entry_reader(f"{tmp_dir}{_shm_folder}/{_shm_entry}")
|
||||
rmtree(f"{tmp_dir}{_shm_folder}")
|
||||
@@ -334,7 +334,7 @@ def sync(): # calls sshync to sync changes to the user's server
|
||||
try:
|
||||
_deletion_database = open(path.expanduser('~/.config/sshyp/deletion_database')).readlines()
|
||||
except (FileNotFoundError, IndexError):
|
||||
print('\nThe deletion database does not exist or is corrupted.\n')
|
||||
print('\n\u001b[38;5;1mError: the deletion database does not exist or is corrupted.\u001b[0m\n')
|
||||
_deletion_database = None
|
||||
s_exit(1)
|
||||
for _file in _deletion_database:
|
||||
@@ -362,7 +362,7 @@ def sync(): # calls sshync to sync changes to the user's server
|
||||
try:
|
||||
_folder_database = open(path.expanduser('~/.config/sshyp/folder_database')).readlines()
|
||||
except (FileNotFoundError, IndexError):
|
||||
print('\nThe folder database does not exist or is corrupted.\n')
|
||||
print('\n\u001b[38;5;1mError: the folder database does not exist or is corrupted.\u001b[0m\n')
|
||||
_folder_database = None
|
||||
s_exit(1)
|
||||
for _folder in _folder_database:
|
||||
@@ -459,7 +459,7 @@ def edit(): # edits the contents of an entry
|
||||
if _entry_name.startswith('/'):
|
||||
_entry_name = _entry_name.replace('/', '', 1)
|
||||
if not Path(f"{directory}{_entry_name}.gpg").is_file():
|
||||
print("\nYou are trying to edit a file that does not exist!\n")
|
||||
print(f"\n\u001b[38;5;1mError: entry ({_entry_name}) does not exist\u001b[0m\n")
|
||||
s_exit(1)
|
||||
_shm_folder, _shm_entry = shm_gen()
|
||||
system(f"{gpg} -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{_entry_name}.gpg'")
|
||||
@@ -508,7 +508,7 @@ def gen(): # generates a password for a new or an existing entry
|
||||
_entry_name = _entry_name.replace('/', '', 1)
|
||||
if argument.startswith('gen update') or argument.startswith('gen -u'):
|
||||
if not Path(f"{directory}{_entry_name}.gpg").is_file():
|
||||
print("\nYou are trying to edit a file that does not exist!\n")
|
||||
print(f"\n\u001b[38;5;1mError: entry ({_entry_name}) does not exist\u001b[0m\n")
|
||||
s_exit(1)
|
||||
else:
|
||||
_username = str(input('Username: '))
|
||||
@@ -547,7 +547,7 @@ def copy_data(): # copies a specified field of an entry to the clipboard
|
||||
del _read_entry[:2]
|
||||
_read_entry = ' '.join(_read_entry)
|
||||
if not Path(f"{directory}{_read_entry}.gpg").is_file():
|
||||
print("\nThe file does not exist!\n")
|
||||
print(f"\n\u001b[38;5;1mError: entry ({_read_entry}) does not exist\u001b[0m\n")
|
||||
s_exit(1)
|
||||
_shm_folder, _shm_entry = shm_gen()
|
||||
system(f"{gpg} -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{_read_entry}.gpg'")
|
||||
|
||||
Reference in New Issue
Block a user