예제 #1
0
    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
예제 #2
0
 def _Encode(self, s):
     """Encode a string that may contain binary data."""
     return common.Encode(s)
예제 #3
0
 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)
예제 #4
0
 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)
예제 #5
0
 def Handle(self):
     blob = interface.GetMessageFile(self.GetArg("sender"),
                                     self.GetArg("recipient"),
                                     self.GetArg("send_timestamp_ms"), True)
     self.SetArg("blob", common.Encode(blob))