update some of the logging commands and fixed logging to logger

This commit is contained in:
2022-09-07 21:43:39 -04:00
parent 641ffacfb4
commit a5ca8d2207

View File

@@ -433,7 +433,7 @@ if __name__ == "__main__":
# login to Bitwarden
logger.info("Trying to login to Bitwarden as {}".format(email))
bitwarden_login = subprocess.run([bitwarden_cli_executable, 'login', '--apikey', '--raw', '--quiet'], capture_output=True)
bitwarden_login = subprocess.run([bitwarden_cli_executable, 'login', '--apikey', '--raw'], capture_output=True)
logger.debug("Bitwarden login output: {}".format(bitwarden_login))
bitwarden_status = json.loads(((subprocess.run([bitwarden_cli_executable, 'status'], capture_output=True)).stdout).decode())
logger.debug("Bitwarden Status: {}".format(bitwarden_status))
@@ -450,20 +450,18 @@ if __name__ == "__main__":
logger.error("Unable to login to account, please check API credentials")
# export to csv and json
logging.info("Exporting vault to both CSV and JSON files.")
logging.debug("Exporting vault to CSV.")
bitwarden_export = (subprocess.run([bitwarden_cli_executable, 'export', '--output', os.path.join(script_directory, 'export.csv') , '--format', 'csv'], capture_output=True).stdout).decode()
logging.debug("Bitwarden export to CSV output: {}".format(bitwarden_export))
logging.debug("Exporting vault to JSON.")
bitwarden_export = (subprocess.run([bitwarden_cli_executable, 'export', '--output', os.path.join(script_directory, 'export.json'), '--format', 'json'], capture_output=True).stdout).decode()
logging.debug("Bitwarden export to JSON output: {}".format(bitwarden_export))
logger.info("Exporting vault to both CSV and JSON files.")
logger.debug("Exporting vault to CSV.")
logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--output', os.path.join(script_directory, 'export.csv') , '--format', 'csv'], capture_output=True).stdout).decode())
logger.debug("Exporting vault to JSON.")
logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--output', os.path.join(script_directory, 'export.json'), '--format', 'json'], capture_output=True).stdout).decode())
del os.environ['BW_CLIENTID']
del os.environ['BW_CLIENTSECRET']
del os.environ["BW_SESSION"]
logger.info("Logging out of your Bitwarden account")
subprocess.run([bitwarden_cli_executable, 'logout', '--quiet'])
logger.debug((subprocess.run([bitwarden_cli_executable, 'logout'], capture_output=True).stdout).decode())
client.close()
sys.exit(0)