From c225756d5517f0b8b4ee39780d7addc493718d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20J=2E=20H=C3=A4u=C3=9Fler?= Date: Tue, 2 Feb 2021 12:15:56 +0100 Subject: [PATCH] temporary fix Azure/azure-sdk-for-python#15358 --- zuschauer.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/zuschauer.py b/zuschauer.py index c02548b..7acb359 100644 --- a/zuschauer.py +++ b/zuschauer.py @@ -487,10 +487,9 @@ def upload(self, path: Path, overwrite: bool=False, asynced: bool=False): failed = True path = path.resolve() if path.exists() and path.is_file(): - with self.service_client: - try: - # Instantiate a new BlobClient - obj_client = self._get_obj_client(path.name) + try: + # Instantiate a new BlobClient + with self._get_obj_client(path.name) as obj_client: # Upload content to block blob with open(path, "rb") as data: if self.storage_type == STORAGES[2]: @@ -498,8 +497,8 @@ def upload(self, path: Path, overwrite: bool=False, asynced: bool=False): else: obj_client.upload_blob(data, blob_type="BlockBlob", overwrite=overwrite, logging_enable=True) failed = False - finally: - pass + finally: + pass return failed else: print(f"{path} does not exist or not a file.") @@ -510,11 +509,10 @@ def _available_containers(self): success = False containers = [] try: - with self.service_client: - if self.storage_type == STORAGES[2]: - containers = list(self.service_client.list_file_systems(logging_enable=True)) - else: - containers = list(self.service_client.list_containers(logging_enable=True)) + if self.storage_type == STORAGES[2]: + containers = list(self.service_client.list_file_systems(logging_enable=True)) + else: + containers = list(self.service_client.list_containers(logging_enable=True)) success = True except BaseException as e: print(e) @@ -715,7 +713,7 @@ def main(args, storageService): configItems = {} # creds provided by arg? - creds = _args.creds + creds = _args.credentials if creds is None and STORECREDENTIALS: # creds saved in keyring? creds = keyring.get_password("zuschauer@drahnreb", f"zs_creds_{platform.node()}")