add a notification in the notification queue of a user
542100
def _add_notification(self, message):
        
        sess = cherrypy.session
        username = sess.get(SESSION_KEY, None)
        if username not in self.notifications:
            self.notifications[username] = []
        self.notifications[username].append(message)
1323137
def notify(self, instance=None, **kwargs):
        
        notified = {}
        for notification_cls in self.registry.values():
            notification = notification_cls()
            if notification.notify(instance=instance, **kwargs):
                notified.update({notification_cls.name: instance._meta.label_lower})
        return notified
668723
def notification_message(self, title, content, icon=""):
        
        code = """
            var options = {
                body: "%(content)s",
                icon: "%(icon)s"
            }
            if (!("Notification" in window)) {
                alert("%(content)s");
            }else if (Notification.permission === "granted") {
                var notification = new Notification("%(title)s", options);
            }else if (Notification.permission !== 'denied') {
                Notification.requestPermission(function (permission) {
                    if (permission === "granted") {
                        var notification = new Notification("%(title)s", options);
                    }
                });
            }
        """ % {'title': title, 'content': content, 'icon': icon}
        self.execute_javascript(code)
244128
def _Notify(username, notification_type, message, object_reference):
  """"""

  # Do not try to notify system users (e.g. Cron).
  if username in aff4_users.GRRUser.SYSTEM_USERS:
    return

  if object_reference:
    uc = object_reference.UnionCast()
    if hasattr(uc, "client_id"):
      message = _HostPrefix(uc.client_id) + message

  n = rdf_objects.UserNotification(
      username=username,
      notification_type=notification_type,
      state=rdf_objects.UserNotification.State.STATE_PENDING,
      message=message,
      reference=object_reference)
  data_store.REL_DB.WriteUserNotification(n)
102973
public void add(T notification) {
        notificationArray.remove(notification.getId());
        notificationArray.put(notification.getId(), notification);
    }
1223255
def _update_notification(self, message=None):
        """"""
        if message is None:
            message = ''
        message_label = self._parts['notification label']
        message_label.config(text=message)
        self._base.update()
519510
public static void addNotification(Notification n) {
        NotificationManager.notifications.add(n);
        logger.fine("New notification added to notifications list. There is currently: " +
                    notifications.size()+" notifications\n Notification added: "
                    +NotificationManager.notifications.get(NotificationManager.notifications.size()-1));
    }
1328843
def create_notification(self, notification_type, label=None, name=None,
            details=None):
        
        return self._notification_manager.create(notification_type,
                label=label, name=name, details=details)
256599
@SuppressWarnings("unchecked")
     public static void addNotification(Event e, String interaction) {
        NotificationManager.notifications.add(new InteractionNotification(getNotificationID(),
                                        NotificationManager.sim.getSchedule().getSteps(), e.getLauncher(), 
                                        interaction, (List<Object>) e.getAffected()));
        logger.fine("New notification added to notifications list. There is currently: " +
                    notifications.size()+" notifications\n Notification added: "
                    +NotificationManager.notifications.get(NotificationManager.notifications.size()-1));
    }
320318
async def send_notification(self, method, args=()):
        ''''''
        message = self.connection.send_notification(Notification(method, args))
        await self._send_message(message)
937204
public function _loadNotificationIntoQueue($notification_entry) {
        $this->queue_manager
            ->connection($this->queue_connection)
            ->pushRaw(json_encode($notification_entry), $this->queue_name);
    }
413396
def notify(self, msg, color='green', notify='true', message_format='text'):
        """"""
        self.message_dict = {
            'message': msg,
            'color': color,
            'notify': notify,
            'message_format': message_format,
        }
        if not self.debug:
            return requests.post(
                self.notification_url,
                json.dumps(self.message_dict),
                headers=self.headers
            )
        else:
            print('HipChat message: <{}>'.format(msg))
            return []
286519
def notify_user(
        self,
        msg,
        level="error",
        rate_limit=None,
        module_name="",
        icon=None,
        title="py3status",
    ):
        
        dbus = self.config.get("dbus_notify")
        if dbus:
            # force msg, icon, title to be a string
            title = u"{}".format(title)
            msg = u"{}".format(msg)
            if icon:
                icon = u"{}".format(icon)
        else:
            msg = u"py3status: {}".format(msg)
        if level != "info" and module_name == "":
            fix_msg = u"{} Please try to fix this and reload i3wm (Mod+Shift+R)"
            msg = fix_msg.format(msg)
        # Rate limiting. If rate limiting then we need to calculate the time
        # period for which the message should not be repeated.  We just use
        # A simple chunked time model where a message cannot be repeated in a
        # given time period. Messages can be repeated more frequently but must
        # be in different time periods.

        limit_key = ""
        if rate_limit:
            try:
                limit_key = time.time() // rate_limit
            except TypeError:
                pass
        # We use a hash to see if the message is being repeated.  This is crude
        # and imperfect but should work for our needs.
        msg_hash = hash(u"{}#{}#{}#{}".format(module_name, limit_key, msg, title))
        if msg_hash in self.notified_messages:
            return
        elif module_name:
            log_msg = 'Module `%s` sent a notification. "%s: %s"' % (
                module_name,
                title,
                msg,
            )
            self.log(log_msg, level)
        else:
            self.log(msg, level)
        self.notified_messages.add(msg_hash)

        try:
            if dbus:
                # fix any html entities
                msg = msg.replace("&", "&amp;")
                msg = msg.replace("<", "&lt;")
                msg = msg.replace(">", "&gt;")
                cmd = ["notify-send"]
                if icon:
                    cmd += ["-i", icon]
                cmd += ["-u", DBUS_LEVELS.get(level, "normal"), "-t", "10000"]
                cmd += [title, msg]
            else:
                py3_config = self.config.get("py3_config", {})
                nagbar_font = py3_config.get("py3status", {}).get("nagbar_font")
                wm_nag = self.config["wm"]["nag"]
                cmd = [wm_nag, "-m", msg, "-t", level]
                if nagbar_font:
                    cmd += ["-f", nagbar_font]
            Popen(cmd, stdout=open("/dev/null", "w"), stderr=open("/dev/null", "w"))
        except Exception as err:
            self.log("notify_user error: %s" % err)
1098294
def _notify_receiver(self, receiver, params, doc):
        """"""
        verb = VMAP[doc['op']]
        ns = doc['ns']
        notification_id = Id(ns + 'Notification:' + str(ObjectId()) + '@' + params['authority'])
        object_id = Id(ns + ':' + str(doc['o']['_id']) + '@' + params['authority'])
        try:
            getattr(receiver, '_'.join([verb, params['obj_name_plural']]))(notification_id, [object_id])
        except AttributeError:
            pass
        return notification_id
467392
def set_message(self, title, msg, typ, url=None):
        
        return self.user.send_notification(title=title,
                                           message=msg,
                                           typ=typ,
                                           url=url)
425466
def notify():
    """"""
    a = TpPd(pd=0x3)
    b = MessageType(mesType=0x3e)  # 00111110
    c = NotificationIndicator()
    packet = a / b / c
    return packet
635179
def do_notification_update(mc, args):
    ''''''
    fields = {}
    fields['notification_id'] = args.id
    fields['name'] = args.name

    fields['type'] = args.type
    fields['address'] = args.address
    if not _validate_notification_period(args.period, args.type.upper()):
        return
    fields['period'] = args.period
    try:
        notification = mc.notifications.update(**fields)
    except (osc_exc.ClientException, k_exc.HttpError) as he:
        raise osc_exc.CommandError('%s\n%s' % (he.message, he.details))
    else:
        print(jsonutils.dumps(notification, indent=2))