def __init__(self, host="127.0.0.1", port=27017, database="vasp", user=None, password=None, collection="tasks", aliases_config=None, default_properties=None): if has_mongo(): try: QueryEngine.__init__(self, host=host, port=port, database=database, user=user, password=password, collection=collection, aliases_config=aliases_config, default_properties=default_properties) _log.warning("Connected to real MongoDB at {}:{}".format(host, port)) return # actully connected! not mocked.. except: _log.debug("Connection to real MongoDB at {}:{} failed. " "This is normal; using mock." .format(host, port)) self.connection = MongoClient(host, port) self.db = self.connection[database] self._user, self._password = user, password self.host = host self.port = port self.database_name = database # colllection name is now a @property. the setter will set "self.collection" internally self.collection_name = collection self.set_aliases_and_defaults(aliases_config=aliases_config, default_properties=default_properties)
def __init__(self, track_operation=None, track_field=None, **kwargs): """Constructor. """ self._tracking_off = False # Set these first because QueryEngine.__init__ calls overridden `collection_name setter()`. assert track_field self._t_op, self._t_field = track_operation, track_field self.collection = None # Now init parent QueryEngine.__init__(self, **kwargs)
def __init__(self, host="127.0.0.1", port=27017, database="vasp", user=None, password=None, collection="tasks", aliases_config=None, default_properties=None): try: QueryEngine.__init__(self, host=host, port=port, database=database, user=user, password=password, collection=collection, aliases_config=aliases_config, default_properties=default_properties) print("@@ connected to real Mongo") return # actully connected! not mocked.. except: pass self.connection = MongoClient(self.host, self.port) self.db = self.connection[database] self._user, self._password = user, password self.host = host self.port = port self.database_name = database self.collection_name = collection self.set_collection(collection=collection) self.set_aliases_and_defaults(aliases_config=aliases_config, default_properties=default_properties)
def __init__(self, host="127.0.0.1", port=27017, database="vasp", user=None, password=None, collection="tasks", aliases_config=None, default_properties=None): try: QueryEngine.__init__(self, host=host, port=port, database=database, user=user, password=password, collection=collection, aliases_config=aliases_config, default_properties=default_properties) print("@@ connected to real Mongo") return # actully connected! not mocked.. except: pass self.connection = MongoClient(self.host, self.port) self.db = self.connection[database] self._user, self._password = user, password self.host = host self.port = port self.database_name = database # colllection name is now a @property. the setter will set "self.collection" internally self.collection_name = collection self.set_aliases_and_defaults(aliases_config=aliases_config, default_properties=default_properties)
def __init__(self, host="127.0.0.1", port=27017, database="vasp", user=None, password=None, collection="tasks", aliases_config=None, default_properties=None): if has_mongo(): try: QueryEngine.__init__(self, host=host, port=port, database=database, user=user, password=password, collection=collection, aliases_config=aliases_config, default_properties=default_properties) _log.warning("Connected to real MongoDB at {}:{}".format( host, port)) return # actully connected! not mocked.. except: _log.debug("Connection to real MongoDB at {}:{} failed. " "This is normal; using mock.".format(host, port)) self.connection = MongoClient(host, port) self.db = self.connection[database] self._user, self._password = user, password self.host = host self.port = port self.database_name = database # colllection name is now a @property. the setter will set "self.collection" internally self.collection_name = collection self.set_aliases_and_defaults(aliases_config=aliases_config, default_properties=default_properties)