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

Class MongoConnectorBase

python3_cron_scripts/libs3/MongoConnectorBase.py:27–249  ·  view source on GitHub ↗

This class is designed for interacting with MongoDB

Source from the content-addressed store, hash-verified

25
26
27class MongoConnectorBase(object):
28 """
29 This class is designed for interacting with MongoDB
30 """
31
32 protocol = "mongodb://"
33 mongo_config_file = "connector.config"
34 m_connection = None
35 _logger = None
36
37 def _log(self):
38 """
39 Get the log
40 """
41 return logging.getLogger(__name__)
42
43 def _init_mongo_connection(self, config, config_location):
44 """Obtains all the parameters from the config file"""
45 protocol = ConnectorUtil.get_config_setting(
46 self._logger,
47 config,
48 config_location,
49 "mongo.protocol",
50 "str",
51 self.protocol,
52 )
53 endpoint = ConnectorUtil.get_config_setting(
54 self._logger, config, config_location, "mongo.host"
55 )
56 path = ConnectorUtil.get_config_setting(
57 self._logger, config, config_location, "mongo.path"
58 )
59 username = ConnectorUtil.get_config_setting(
60 self._logger, config, config_location, "mongo.username"
61 )
62 password = ConnectorUtil.get_config_setting(
63 self._logger, config, config_location, "mongo.password"
64 )
65 cacert = ConnectorUtil.get_config_setting(
66 self._logger, config, config_location, "mongo.ca_cert"
67 )
68
69 if username != "" and password != "":
70 connection_string = (
71 protocol
72 + username
73 + ":"
74 + urllib.parse.quote(password)
75 + "@"
76 + endpoint
77 + path
78 )
79 else:
80 connection_string = protocol + endpoint + path
81
82 if cacert != "":
83 client = MongoClient(connection_string, tls=True, tlsCAFile=cacert)
84 else:

Callers 2

__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected