def post(self): client = Client.get_by_client_id(self.request.authentication.client_id) server = client.server if not server.active: self.abort(404) status_code = 200 line = self.request.form.line.data zone = self.request.form.zone.data existing_line = LogLine.lookup_line(server.key, line) if existing_line is None: log_line = LogLine.create(server, line, zone) if log_line is not None: status_code = 201 self.json_response({}, status_code=status_code)
def post(self, key): try: server_key = ndb.Key(urlsafe=key) server = server_key.get() if server is None or ON_SERVER: self.abort(404) file = self.request.POST['file'] import StringIO from models import LogLine buf = StringIO.StringIO(file.value) for raw_line in buf.readlines(): line = raw_line.decode('ISO-8859-2', errors='ignore') line = line.strip() existing_line = LogLine.lookup_line(server.key, line) if existing_line is None: log_line = LogLine.create(server, line, 'UTC') logging.info(log_line.line) except Exception, e: logging.error(u"Error POSTing server: {0}".format(e)) self.abort(404)