Writes the body of an event object to the output.

    Args:
      event (EventObject): event.
177644
def WriteEventBody(self, event):
    
    inode = getattr(event, 'inode', None)
    if inode is None:
      event.inode = 0

    try:
      message, _ = self._output_mediator.GetFormattedMessages(event)
    except errors.WrongFormatter:
      message = None

    if message:
      event.message = message

    json_dict = self._JSON_SERIALIZER.WriteSerializedDict(event)
    json_string = json.dumps(json_dict, sort_keys=True)
    # dumps() returns an ascii-encoded byte string in Python 2.
    if py2to3.PY_2:
      json_string = codecs.decode(json_string, 'ascii')
    self._output_writer.Write(json_string)
    self._output_writer.Write('\n')
355903
def add_event(self, event):
        
        if not isinstance(event, event_pb2.Event):
            raise TypeError("Expected an event_pb2.Event proto, "
                            " but got %s" % type(event))
        self._async_writer.write(event.SerializeToString())
695187
def save_event(event)
      method = event.new_event? ? :post : :put
      body = event.use_quickadd? ? nil : event.to_json
      notifications = "sendNotifications=#{event.send_notifications?}"
      query_string =  if event.use_quickadd?
                        "/quickAdd?#{notifications}&text=#{event.title}"
                      elsif event.new_event?
                        "?#{notifications}"
                      else # update existing event.
                        "/#{event.id}?#{notifications}"
                      end

      send_events_request(query_string, method, body)
    end
494389
def dispatch_event(self, event):
        
        if self.config["debug"]:
            self.py3_wrapper.log("received event {}".format(event))

        # usage variables
        event["index"] = event.get("index", "")
        instance = event.get("instance", "")
        name = event.get("name", "")

        # composites have an index which is passed to i3bar with
        # the instance.  We need to separate this out here and
        # clean up the event.  If index
        # is an integer type then cast it as such.
        if " " in instance:
            instance, index = instance.split(" ", 1)
            try:
                index = int(index)
            except ValueError:
                pass
            event["index"] = index
            event["instance"] = instance

        if self.config["debug"]:
            self.py3_wrapper.log(
                'trying to dispatch event to module "{}"'.format(
                    "{} {}".format(name, instance).strip()
                )
            )

        # guess the module config name
        module_name = "{} {}".format(name, instance).strip()

        default_event = False
        module_info = self.output_modules.get(module_name)
        module = module_info["module"]
        # execute any configured i3-msg command
        # we do not do this for containers
        # modules that have failed do not execute their config on_click
        if module.allow_config_clicks:
            button = event.get("button", 0)
            on_click = self.on_click.get(module_name, {}).get(str(button))
            if on_click:
                task = EventClickTask(module_name, event, self, on_click)
                self.py3_wrapper.timeout_queue_add(task)
            # otherwise setup default action on button 2 press
            elif button == 2:
                default_event = True

        # do the work
        task = EventTask(module_name, event, default_event, self)
        self.py3_wrapper.timeout_queue_add(task)
288274
def record_event(self, event: Event) -> None:
        
        from polyaxon.celery_api import celery_app
        from polyaxon.settings import EventsCeleryTasks

        if not event.ref_id:
            event.ref_id = self.get_ref_id()
        serialized_event = event.serialize(dumps=False,
                                           include_actor_name=True,
                                           include_instance_info=True)

        celery_app.send_task(EventsCeleryTasks.EVENTS_TRACK, kwargs={'event': serialized_event})
        celery_app.send_task(EventsCeleryTasks.EVENTS_LOG, kwargs={'event': serialized_event})
        celery_app.send_task(EventsCeleryTasks.EVENTS_NOTIFY, kwargs={'event': serialized_event})
        # We include the instance in the serialized event for executor
        serialized_event['instance'] = event.instance
        self.executor.record(event_type=event.event_type, event_data=serialized_event)
1294791
def add_event(self, event, prepend=False):
        
        if prepend:
            self._events.insert(0, event)
        else:
            self._events.append(event)
269709
def put(self, event, *args, **kwargs):
        
        self._queue.put((event, args, kwargs))
567669
def post_event(self, event):
        

        if self.disabled is True:
            logging.error('Posting has been disabled. '
                          'See previous errors for details.')
            return(False)

        payload = json.dumps(
            [event], default=lambda o: o.__dict__, sort_keys=True)
        logging.debug(payload)
        try:
            headers = {'Content-Type': 'application/json',
                       'User-Agent': self.agent}
            request = urllib2.Request(
                self.eventurl, data=payload, headers=headers)
            resp = urllib2.urlopen(request)
            logging.debug("Response code: %d", resp.getcode())
            resp.close()

            return(True)

        except urllib2.HTTPError as e:
            logging.debug("Response code: %d", e.code)

            if e.code in self.kill_codes:
                self.disabled = True
                logging.exception('Posting has been disabled.'
                                  'See previous errors for details.')
            else:
                logging.exception(
                    'error posting payload to api ingest endpoint (%s): %s',
                    self.eventurl, e)

        except Exception as e:
            logging.exception(
                'error posting payload to api ingest endpoint (%s): %s',
                self.eventurl, e)
548317
def write_events(self, outname):
        
        self.make_output_dir(outname)

        if '.hdf' in outname:
            self.write_to_hdf(outname)
        else:
            raise ValueError('Cannot write to this format')
978722
def user_write_events(self) -> List[str]:
        
        return [event_type for event_type, event in self.items if event.get_event_action()
                in event_actions.WRITE_ACTIONS]
720955
def WriteEventBody(self, event):
    
    latitude = getattr(event, 'latitude', None)
    longitude = getattr(event, 'longitude', None)
    if latitude is not None and longitude is not None:
      placemark_xml_element = ElementTree.Element('Placemark')

      name_xml_element = ElementTree.SubElement(placemark_xml_element, 'name')

      name_xml_element.text = 'PLACEHOLDER FOR EVENT IDENTIFIER'

      description_xml_element = ElementTree.SubElement(
          placemark_xml_element, 'description')
      # TODO: move the description formatting into this output module.
      description_xml_element.text = (
          rawpy.NativePythonFormatterHelper.GetFormattedEventObject(event))

      point_xml_element = ElementTree.SubElement(
          placemark_xml_element, 'Point')

      coordinates_xml_element = ElementTree.SubElement(
          point_xml_element, 'coordinates')
      coordinates_xml_element.text = '{0!s},{1!s}'.format(longitude, latitude)

      # Note that ElementTree.tostring() will appropriately escape
      # the input data.
      xml_string = ElementTree.tostring(placemark_xml_element)

      output_text = codecs.decode(xml_string, self._output_mediator.encoding)
      self._output_writer.Write(output_text)
701895
public void processEvent(EventObject event) {
    if (event instanceof RequestEvent) {
      processRequestEvent((RequestEvent) event);
    } else {
      LOG.error("invalid event type received: " + event.getClass().getName() + ": "
          + event.toString());
    }
  }
1280472
public synchronized void insert_event(EventData event) {
        events.add(event);
        while (events.size() > max_size)
            events.remove(0);
    }
1134618
def AddEvent(self, event):
    
    self._RaiseIfNotWritable()

    self._storage_file.AddEvent(event)
    self.number_of_events += 1

    self._UpdateCounters(event)
765161
@Override
    public synchronized void write(final Event event) throws IOException
    {
        if (!acceptsEvents) {
            log.warn("Writer not ready, discarding event: {}", event);
            return;
        }

        delegate.write(event);
        uncommittedWriteCount++;

        commitIfNeeded();
    }
731458
def dispatch_event(event):
    

    try:
      if event.http_verb == enums.HTTPVerbs.GET:
        requests.get(event.url, params=event.params, timeout=REQUEST_TIMEOUT).raise_for_status()
      elif event.http_verb == enums.HTTPVerbs.POST:
        requests.post(
          event.url, data=json.dumps(event.params), headers=event.headers, timeout=REQUEST_TIMEOUT
        ).raise_for_status()

    except request_exception.RequestException as error:
      logging.error('Dispatch event failed. Error: %s' % str(error))
1169759
@Transactional
	public void save(Event event) {
		Event merged = em.merge(event);
		em.flush();
		event.setId(merged.getId());
	}