Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
drahnreb committed Feb 2, 2021
1 parent ee1a475 commit c225756
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions zuschauer.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,19 +487,18 @@ 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]:
obj_client.upload_data(data, length=None, overwrite=overwrite, logging_enable=True)
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.")
Expand All @@ -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)
Expand Down Expand Up @@ -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()}")
Expand Down

0 comments on commit c225756

Please sign in to comment.