Coverage for src/pyenbc/remote/azure_drive.py: 53%
15 statements
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-20 05:47 +0200
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-20 05:47 +0200
1"""
2@file
3@brief Common API to upload, download data from Azure
5.. versionadded:: 1.1
6"""
7from .cloud_transfer import CloudTransfer
8from .azure_connection import AzureClient
11class AzureDrive(CloudTransfer):
12 """
13 defines a common API for a remote storage
15 .. versionadded:: 1.1
16 """
18 def __init__(self, blob, key, fLOG=None, container="backup"):
19 """
20 constructor
22 @param blob blob storage
23 @param key key
24 @param container container name
25 @param fLOG logging function
26 """
27 CloudTransfer.__init__(self, blob, key, fLOG)
28 self._client = AzureClient(blob, key)
29 self._container = container
31 def connect(self):
32 """
33 connect
34 """
35 self._service = self._client.open_blob_service()
37 def close(self):
38 """
39 close the connection
40 """
41 pass
43 def upload_data(self, remote_path, data):
44 """
45 upload binary data
47 @param remote_path path on the remote drive
48 @param data bytes
49 @return boolean
50 """
51 self._client.upload_data(
52 self._service, self._container, remote_path, data)
54 def download_data(self, remote_path):
55 """
56 download binary data
58 @param remote_path path on the remote drive
59 @return data (bytes)
60 """
61 return self._client.download_data(self._service, self._container, remote_path)