From 66a026e3276a5ca634baa2fb0bad6754ee2e5d94 Mon Sep 17 00:00:00 2001 From: Cuan Date: Tue, 19 Apr 2022 01:55:12 -0400 Subject: [PATCH] Added new, colored syncing operation messages --- bin/sshync.py | 8 ++++---- bin/sshyp | 11 ++++++----- bin/sshypRemote.py | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/bin/sshync.py b/bin/sshync.py index dd2b121..fe76bad 100755 --- a/bin/sshync.py +++ b/bin/sshync.py @@ -85,19 +85,19 @@ def run_profile(_profile_dir): if _title in _index_r[0]: # compare mod times and sync if int(_index_l[1][_i]) > int(_index_r[1][_i]): - print(f"[{_title[:-4]}] Local is newer, uploading...") + print(f"\u001b[38;5;4m{_title[:-4]}\u001b[0m is newer locally, uploading...") system(f"scp -pq -P {_user_data[2]} -i '{_user_data[5]}' '{_user_data[3]}{_title}' " f"'{_user_data[0]}@{_user_data[1]}:{_user_data[4]}{'/'.join(_title.split('/')[:-1]) + '/'}'") elif int(_index_l[1][_i]) < int(_index_r[1][_i]): - print(f"[{_title[:-4]}] Remote is newer, downloading...") + print(f"\u001b[38;5;2m{_title[:-4]}\u001b[0m is newer remotely, downloading...") system(f"scp -pq -P {_user_data[2]} -i '{_user_data[5]}' '{_user_data[0]}@{_user_data[1]}:" f"{_user_data[4]}{_title}' '{_user_data[3]}{'/'.join(_title.split('/')[:-1]) + '/'}'") else: - print(f"[{_title[:-4]}] Not on remote server, uploading...") + print(f"\u001b[38;5;4m{_title[:-4]}\u001b[0m is not on remote server, uploading...") system(f"scp -pq -P {_user_data[2]} -i '{_user_data[5]}' '{_user_data[3]}{_title}' " f"'{_user_data[0]}@{_user_data[1]}:{_user_data[4]}{'/'.join(_title.split('/')[:-1]) + '/'}'") for _title in _index_r[0]: if _title not in _index_l[0]: - print(f"[{_title[:-4]}] Not in local directory, downloading...") + print(f"\u001b[38;5;2m{_title[:-4]}\u001b[0m is not in local directory, downloading...") system(f"scp -pq -P {_user_data[2]} -i '{_user_data[5]}' '{_user_data[0]}@{_user_data[1]}:" f"{_user_data[4]}{_title}' '{_user_data[3]}{'/'.join(_title.split('/')[:-1]) + '/'}'") diff --git a/bin/sshyp b/bin/sshyp index ccbd348..0753036 100755 --- a/bin/sshyp +++ b/bin/sshyp @@ -286,16 +286,16 @@ def sync(): # calls sshync to sync changes to the user's server for _file in _deletion_database: if _file[:-1].endswith('/'): try: - print(f"Removing folder {path.expanduser('~/.password-pasture/')}{_file[:-1]}...\n") + print(f"\u001b[38;5;208m{_file[:-1]}\u001b[0m has been sheared, removing...") rmtree(f"{path.expanduser('~/.password-pasture/')}{_file[:-1]}") except FileNotFoundError: - print('Folder does not exist locally.\n') + print('Folder does not exist locally.') else: try: - print(f"Removing entry {path.expanduser('~/.password-pasture/')}{_file[:-1]}...\n") + print(f"\u001b[38;5;208m{_file[:-1]}\u001b[0m has been sheared, removing...") remove(f"{path.expanduser('~/.password-pasture/')}{_file[:-1]}.gpg") except (FileNotFoundError, IsADirectoryError): - print('File does not exist locally.\n') + print('File does not exist locally.') # check for new folders system(f"ssh -i '{path.expanduser('~/.ssh/sshyp')}' -p {port} {username_ssh}@{ip} \"python -c 'import sshypRemote" f"; sshypRemote.folder_check()'\"") @@ -311,7 +311,8 @@ def sync(): # calls sshync to sync changes to the user's server if Path(f"{path.expanduser('~')}{_folder[:-1]}").is_dir(): pass else: - print(f"Adding folder {path.expanduser('~')}{_folder[:-1]}...\n") + print(f"\u001b[38;5;2m{_folder.replace('/.password-pasture/', '')[:-1]}/\u001b[0m does not exist locally, " + f"creating...") Path(f"{path.expanduser('~')}{_folder[:-1]}").mkdir(0o700, parents=True, exist_ok=True) # set permissions before uploading system('find ' + directory + ' -type d -exec chmod -R 700 {} +') diff --git a/bin/sshypRemote.py b/bin/sshypRemote.py index 30e31f6..591b3b1 100755 --- a/bin/sshypRemote.py +++ b/bin/sshypRemote.py @@ -14,12 +14,12 @@ def delete(_file_path): try: rmtree(f"{expanduser('~/.password-pasture/')}{_file_path}") except FileNotFoundError: - print('\nFolder does not exist remotely.') + print('Folder does not exist remotely.') else: try: remove(f"{expanduser('~/.password-pasture/')}{_file_path}.gpg") except FileNotFoundError: - print('\nFile does not exist remotely.') + print('File does not exist remotely.') for _device_name in listdir(expanduser('~/.config/sshyp/devices')): open(f"{expanduser('~/.config/sshyp/deleted/')}{_file_path.replace('/', '@')}^&*{_device_name}", 'w')