コード例 #1
0
ファイル: tasks.py プロジェクト: OpenLightingProject/rdm-app
  def get(self):
    key = self.request.get('key')
    responder = Responder.get(key)
    if not responder:
      return

    if responder.image_url and not responder.image_data:
      fetcher = ImageFetcher()
      blob_key = fetcher.FetchAndSaveImage(responder.image_url)

      if blob_key:
        responder.image_data = blob_key
        responder.image_serving_url = images.get_serving_url(blob_key)
        responder.put()
    return
コード例 #2
0
    def get(self):
        key = self.request.get('key')
        responder = Responder.get(key)
        if not responder:
            return

        if responder.image_url and not responder.image_data:
            fetcher = ImageFetcher()
            blob_key = fetcher.FetchAndSaveImage(responder.image_url)

            if blob_key:
                responder.image_data = blob_key
                responder.image_serving_url = images.get_serving_url(blob_key)
                responder.put()
        return
コード例 #3
0
    def GetTemplateData(self):
        pid = self.LookupPIDFromRequest()
        if not pid:
            self.error(404)
            return

        supported_by = []
        for responder_key in pid.responders:
            responder = Responder.get(responder_key)
            if responder:
                supported_by.append({
                    'name': responder.model_description,
                    'manufacturer': responder.manufacturer.esta_id,
                    'model': responder.device_model_id,
                })
        supported_by.sort(key=lambda x: x['name'])

        output = {
            'link': pid.link,
            'manufacturer_name': pid.manufacturer.name,
            'manufacturer_id': pid.manufacturer.esta_id,
            'notes': pid.notes,
            'pid_id': pid.pid_id,
            'pid_name': pid.name,
            'supported_by': supported_by,
        }

        if pid.get_command:
            command = self.BuildCommand(pid.get_command)
            output['get_command'] = command

        if pid.discovery_command:
            command = self.BuildCommand(pid.discovery_command)
            output['discovery_command'] = command

        if pid.set_command:
            command = self.BuildCommand(pid.set_command)
            output['set_command'] = command
        return output