Skip to content

Commit

Permalink
Fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
JimMadge committed Sep 22, 2023
1 parent 33e3d86 commit 3b0a773
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions data_safe_haven/external/api/azure_cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Interface to the Azure CLI"""
import subprocess
import json
import subprocess
from dataclasses import dataclass
from shutil import which

Expand All @@ -23,10 +23,8 @@ def __init__(self):

self.path = which("az")
if self.path is None:
raise DataSafeHavenAzureError(
"Unable to find Azure CLI executable in your path.\n"
"Please ensure that Azure CLI is installed"
)
msg = "Unable to find Azure CLI executable in your path.\nPlease ensure that Azure CLI is installed"
raise DataSafeHavenAzureError(msg)

self._account = None

Expand All @@ -41,19 +39,17 @@ def account(self) -> AzureCliAccount:
try:
result_dict = json.loads(result)
except json.JSONDecodeError as exc:
raise DataSafeHavenAzureError(
"Unable to parse Azure CLI output as JSON\n{result}"
) from exc
msg = f"Unable to parse Azure CLI output as JSON\n{result}"
raise DataSafeHavenAzureError(msg) from exc

self._account = AzureCliAccount(
name=result_dict.get('user').get('name'),
id_=result_dict.get('id'),
tenant_id=result_dict.get('tenantId'),
name=result_dict.get("user").get("name"),
id_=result_dict.get("id"),
tenant_id=result_dict.get("tenantId"),
)

except subprocess.CalledProcessError as exc:
raise DataSafeHavenAzureError(
"Error getting account information from Azure CLI"
) from exc
msg = "Error getting account information from Azure CLI"
raise DataSafeHavenAzureError(msg) from exc

return self._account

0 comments on commit 3b0a773

Please sign in to comment.