def post(self): # Update server info j = self.request.body[32:] info = self.validate_request() if not info: if config.is_debug(): self.response.set_status(400, 'not valid') return # Update the model. key = models.serverinfomodel_key(info['name'], info['start_utc']) obj = models.ServerInfoModel.get(key) if not obj: obj = models.ServerInfoModel(key_name=key.name()) # Save the command command = obj.command obj.json = j obj.command = '' obj.expires_utc = info['expires_utc'] obj.put() # Update the cache now rather than just invalidating, so the latency # isn't on a client request self.gen_json() # Return command if there is one if command: # Use this mime type for simplicity, and so GAE doesn't strip # out Content-Length self.response.headers['Content-Type'] = 'binary/octet-stream' self.response.headers['Content-Length'] = len(command) self.response.out.write(command)
def send_command(info, command): # Update the model with the command key = models.serverinfomodel_key(info['name'], info['start_utc']) obj = models.ServerInfoModel.get(key) if obj: obj.command = command obj.put()