MCPcopy Create free account
hub / github.com/adobe/Marinus / StorageManager

Class StorageManager

python3_cron_scripts/libs3/StorageManager.py:29–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28
29class StorageManager(object):
30 AZURE_BLOB = "azure_blob"
31 AWS_S3 = "aws_s3"
32 LOCAL_FILESYSTEM = "local_filesystem"
33
34 TEXT_MODE = "text"
35 BYTES_MODE = "bytes"
36
37 storage_location = LOCAL_FILESYSTEM
38 _storage_config_file = "connector.config"
39
40 _logger = None
41 _log_level = None
42
43 _instance = None
44
45 def _log(self):
46 """
47 Get the log
48 """
49 return logging.getLogger(__name__)
50
51 def __init__(self, location=None, config_file="", log_level=None) -> None:
52 """
53 Initialize the instance
54 """
55
56 self._logger = self._log()
57 if log_level is not None:
58 self._logger.setLevel(log_level)
59 self._log_level = log_level
60
61 if location not in [self.LOCAL_FILESYSTEM, self.AWS_S3, self.AZURE_BLOB]:
62 self._logger("Unknown logging location provided. Exiting")
63 exit(1)
64
65 if config_file != "":
66 self._storage_config_file = config_file
67
68 config = configparser.ConfigParser()
69 list = config.read(self._storage_config_file)
70 if len(list) == 0:
71 self._logger.error("Error: Could not find the config file")
72 exit(1)
73
74 if location is not None and location != "":
75 self.storage_location = location
76 else:
77 self.storage_location = ConnectorUtil.get_config_setting(
78 self._logger, config, "DefaultStorage", "storage.location", "str", ""
79 )
80 if self.storage_location is None or self.storage_location == "":
81 self.storage_location = self.LOCAL_FILESYSTEM
82
83 # There is a classier (pun intended) way to do this.
84 # However, this is functional for now.
85 if self.storage_location == self.AZURE_BLOB:
86 self._instance = AzureStorageManager.AzureStorageManager(

Callers 1

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected