def _add_roll_parameters_without_checking_for_existing_entry(self, roll_parameters_object, instrument_code):

        roll_parameters_object_dict = roll_parameters_object.as_dict()
        roll_parameters_object_dict['instrument_code'] = instrument_code
        cleaned_object_dict = mongo_clean_ints(roll_parameters_object_dict)
        self._mongo.collection.insert_one(cleaned_object_dict)
        self.log.terse("Added %s to %s" % (instrument_code, self.name))
Exemplo n.º 2
0
 def _add_instrument_data_without_checking_for_existing_entry(
         self, instrument_object):
     instrument_object_dict = instrument_object.as_dict()
     cleaned_object_dict = mongo_clean_ints(instrument_object_dict)
     self._mongo.collection.insert_one(cleaned_object_dict)
     self.log.terse("Added %s to %s" %
                    (instrument_object.instrument_code, self.name))
Exemplo n.º 3
0
    def add_data(self, key: str, data_dict: dict, allow_overwrite = False, clean_ints = True):
        if clean_ints:
            cleaned_data_dict = mongo_clean_ints(data_dict)
        else:
            cleaned_data_dict = copy(data_dict)

        if self.key_is_in_data(key):
            if allow_overwrite:
                self._update_existing_data_with_cleaned_dict(key, cleaned_data_dict)
            else:
                raise existingData("Can't overwite existing data %s/%s for %s" % (self.key_name, key, self.name))
        else:
            self._add_new_cleaned_dict(key, cleaned_data_dict)
Exemplo n.º 4
0
    def add_data(self, dict_of_keys: dict, data_dict: dict, allow_overwrite = False, clean_ints = True):
        if clean_ints:
            cleaned_data_dict = mongo_clean_ints(data_dict)
        else:
            cleaned_data_dict = copy(data_dict)

        if self.key_dict_is_in_data(dict_of_keys):
            if allow_overwrite:
                self._update_existing_data_with_cleaned_dict(dict_of_keys, cleaned_data_dict)
            else:
                raise existingData("Can't overwite existing data %s for %s" % (str(dict_of_keys), self.name))
        else:
            self._add_new_cleaned_dict(dict_of_keys, cleaned_data_dict)
Exemplo n.º 5
0
    def add_data(self, key, data_dict: dict, allow_overwrite = False, clean_ints = True):
        if clean_ints:
            cleaned_data_dict = mongo_clean_ints(data_dict)
        else:
            cleaned_data_dict = copy(data_dict)

        if self.key_is_in_data(key):
            if allow_overwrite:
                self._update_existing_data_with_cleaned_dict(key, cleaned_data_dict)
            else:
                raise existingData("Can't overwite existing data %s/%s for %s" % (self.key_name, key, self.name))
        else:
            try:
                self._add_new_cleaned_dict(key, cleaned_data_dict)
            except:
                ## this could happen if the key has just been added most likely for logs
                raise existingData("Can't overwite existing data %s/%s for %s" % (self.key_name, key, self.name))