From b9477e29433abf44b5d6043d7f59eb06288fcfe5 Mon Sep 17 00:00:00 2001 From: John Gaunt Date: Fri, 30 Dec 2022 16:06:12 -0500 Subject: [PATCH] removed for loop for bad export --- bitwardenBackup.py | 48 ++++++++-------------------------------------- 1 file changed, 8 insertions(+), 40 deletions(-) diff --git a/bitwardenBackup.py b/bitwardenBackup.py index b3434bc..d1ce33e 100644 --- a/bitwardenBackup.py +++ b/bitwardenBackup.py @@ -458,29 +458,11 @@ if __name__ == "__main__": logger.info("Exporting vault to both CSV and JSON files") logger.debug("Exporting vault to CSV") file_name = 'Bitwarden {} Export {}'.format(email, datetime_string) - while True: - logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--output', os.path.join(working_directory, '{}.csv'.format(file_name)) , '--format', 'csv'], capture_output=True).stdout).decode()) - time.sleep(1) - file_size = os.path.getsize(os.path.join(working_directory, '{}.csv'.format(file_name))) - if (file_size > 0): - break - else: - logger.info("CSV export did not run correctly, running export again") - if os.path.exists(os.path.join(working_directory, '{}.csv'.format(file_name))): - os.remove(os.path.join(working_directory, '{}.csv'.format(file_name))) - time.sleep(5) + logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--output', os.path.join(working_directory, '{}.csv'.format(file_name)) , '--format', 'csv'], capture_output=True).stdout).decode()) + time.sleep(1) logger.debug("Exporting vault to JSON") - while True: - logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--output', os.path.join(working_directory, '{}.json'.format(file_name)), '--format', 'json'], capture_output=True).stdout).decode()) - time.sleep(1) - file_size = os.path.getsize(os.path.join(working_directory, '{}.json'.format(file_name))) - if (file_size > 56): - break - else: - logger.info("JSON export did not run correctly, running export again") - if os.path.exists(os.path.join(working_directory, '{}.json'.format(file_name))): - os.remove(os.path.join(working_directory, '{}.json'.format(file_name))) - time.sleep(5) + logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--output', os.path.join(working_directory, '{}.json'.format(file_name)), '--format', 'json'], capture_output=True).stdout).decode()) + time.sleep(1) # looking for Organizations # look for organizations @@ -493,25 +475,11 @@ if __name__ == "__main__": logger.info("Exporting organization {} vault to both CSV and JSON files".format(organization['name'])) logger.debug("Exporting organization vault to CSV") file_name = 'Bitwarden Organization {} Export {}'.format(organization['name'], datetime_string) - while True: - logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--organizationid', '{}'.format(organization['id']), '--output', os.path.join(working_directory, '{}.csv'.format(file_name)), '--format', 'csv'], capture_output=True).stdout).decode()) - time.sleep(1) - file_size = os.path.getsize(os.path.join(working_directory, '{}.csv'.format(file_name))) - if (file_size > 0): - break - else: - logger.info("CSV export did not run correctly, running export again") - time.sleep(5) + logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--organizationid', '{}'.format(organization['id']), '--output', os.path.join(working_directory, '{}.csv'.format(file_name)), '--format', 'csv'], capture_output=True).stdout).decode()) + time.sleep(1) logger.debug("Exporting organization vault to JSON") - while True: - logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--organizationid', '{}'.format(organization['id']), '--output', os.path.join(working_directory, '{}.json'.format(file_name)), '--format', 'json'], capture_output=True).stdout).decode()) - time.sleep(1) - file_size = os.path.getsize(os.path.join(working_directory, '{}.json'.format(file_name))) - if (file_size > 56): - break - else: - logger.info("JSON export did not run correctly, running export again") - time.sleep(5) + logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--organizationid', '{}'.format(organization['id']), '--output', os.path.join(working_directory, '{}.json'.format(file_name)), '--format', 'json'], capture_output=True).stdout).decode()) + time.sleep(1) logger.info("Downlading attachments...") bitwarden_items = json.loads(((subprocess.run([bitwarden_cli_executable, 'list', 'items'], capture_output=True)).stdout).decode())