def Update(self): """Update the datastore with the new data. This doesn't remove old models since why would we want to do that? Returns: A tuple in the form (added, updated), with the number of entities added or updated. """ added = [] updated = [] for manufacturer_id, models in self._model_data.iteritems(): manufacturer = self._LookupManufacturer(manufacturer_id) if not manufacturer: logging.error('No manufacturer found for 0x%hx' % manufacturer_id) continue for model_info in models: was_added, was_modified = self._updater.UpdateResponder( manufacturer, model_info) model_description = common.Encode( model_info.get('model_description')) if model_description is None: model_description = ('RDM Model 0x%04x' % model_info.get('device_model', 0)) if was_added: added.append(model_description) elif was_modified: updated.append(model_description) return added, updated
def _Encode(self, s): """Encode a string that may contain binary data.""" return common.Encode(s)
def testSetIntro(self): audio = testutils.Resource("intro.aac") self.api.Call("/account/set_intro", blob=common.Encode(audio)) out_audio = interface.GetForUid(model.IntroFile, testutils.DEFAULT_UID).blob self.assertEqual(audio, out_audio)
def testSetImage(self): img = testutils.Resource("icon.png") self.api.Call("/account/set_image", blob=common.Encode(img)) out_img = interface.GetForUid(model.ImageFile, testutils.DEFAULT_UID).blob self.assertEqual(img, out_img)
def Handle(self): blob = interface.GetMessageFile(self.GetArg("sender"), self.GetArg("recipient"), self.GetArg("send_timestamp_ms"), True) self.SetArg("blob", common.Encode(blob))