remove unneeded array and added time for sleep between attachment downloads

This commit is contained in:
2022-09-08 20:17:31 -04:00
parent b1077dc4be
commit 4ac0a2db37

View File

@@ -11,6 +11,7 @@ import base64
import optparse import optparse
import hmac as pyhmac import hmac as pyhmac
import datetime import datetime
import time
from kmip.core import enums from kmip.core import enums
from kmip.pie import client from kmip.pie import client
@@ -472,7 +473,6 @@ if __name__ == "__main__":
logger.info("Looking for items with attachments") logger.info("Looking for items with attachments")
bitwarden_items = json.loads(((subprocess.run([bitwarden_cli_executable, 'list', 'items'], capture_output=True)).stdout).decode()) bitwarden_items = json.loads(((subprocess.run([bitwarden_cli_executable, 'list', 'items'], capture_output=True)).stdout).decode())
bitwarden_items_with_attachments = ()
for item in bitwarden_items: for item in bitwarden_items:
logger.debug("Working on item {} ({})".format(item['name'], item['id'])) logger.debug("Working on item {} ({})".format(item['name'], item['id']))
if "attachments" in item: if "attachments" in item:
@@ -481,13 +481,9 @@ if __name__ == "__main__":
for attachment in item['attachments']: for attachment in item['attachments']:
logger.debug("Downloading attachment ({}) with name {} to folder {}".format(attachment['id'], attachment['name'], attachment_folder_name)) logger.debug("Downloading attachment ({}) with name {} to folder {}".format(attachment['id'], attachment['name'], attachment_folder_name))
logger.debug((subprocess.run([bitwarden_cli_executable, 'get', 'attachment', attachment['id'], '--itemid', item['id'], '--output', os.path.join(attachment_folder_name, attachment['filename'])], capture_output=True).stdout).decode()) logger.debug((subprocess.run([bitwarden_cli_executable, 'get', 'attachment', attachment['id'], '--itemid', item['id'], '--output', os.path.join(attachment_folder_name, attachment['filename'])], capture_output=True).stdout).decode())
time.sleep(1)
else: else:
logger.debug("Item has no attachments") logger.debug("Item has no attachments")
else: else:
logger.error("Unable to unlock vault, please check vault password") logger.error("Unable to unlock vault, please check vault password")
else: else: