removed for loop for bad export

This commit is contained in:
2022-12-30 16:06:12 -05:00
parent ce40b1ed5d
commit b9477e2943

View File

@@ -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())