This file is indexed.

/usr/bin/bzr-notify is in bzr-gtk 0.103.0+bzr792-1ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
#!/usr/bin/python

"""Run the bzr tray icon.

This is a background program which will pop up a notification on the users
screen when a commit occurs.
"""

from bzrlib.plugin import load_plugins
load_plugins()

from bzrlib.plugins.gtk.commands import open_display

from bzrlib.plugins.gtk.notify import NotifyPopupMenu
Gtk = open_display()

import cgi
import sys

import dbus
import dbus.service
from gi.repository import GObject
from gi.repository import Notify

from bzrlib.bzrdir import BzrDir
from bzrlib.osutils import format_date
from bzrlib.transport import get_transport

menu = NotifyPopupMenu()
try:
    from gi.repository import AppIndicator3
except ImportError:
    icon = Gtk.StatusIcon.new_from_icon_name("bzr-panel")
    icon.connect('popup-menu', menu.display)
    icon.set_visible(False)
    hide_icon = lambda: icon.set_visible(False)
    show_icon = lambda: icon.set_visible(True)
else:
    indicator = AppIndicator3.Indicator.new(
        "bzr-gtk-notify", "bzr-panel", AppIndicator3.IndicatorCategory.OTHER)
    indicator.set_status (AppIndicator3.IndicatorStatus.PASSIVE)
    indicator.set_attention_icon("bzr-panel")
    indicator.set_menu(menu)
    hide_icon = lambda: indicator.set_status (
        AppIndicator3.IndicatorStatus.PASSIVE)
    show_icon = lambda: indicator.set_status (
        AppIndicator3.IndicatorStatus.ATTENTION)

if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
    import dbus.glib
BROADCAST_INTERFACE = "org.bazaarvcs.plugins.dbus.Broadcast"
bus = dbus.SessionBus()

def catch_branch(revision_id, urls):
    # TODO: show all the urls, or perhaps choose the 'best'.
    url = urls[0]
    try:
        if isinstance(revision_id, unicode):
            revision_id = revision_id.encode('utf8')
        transport = get_transport(url)
        a_dir = BzrDir.open_from_transport(transport)
        branch = a_dir.open_branch()
        revno = branch.revision_id_to_revno(revision_id)
        revision = branch.repository.get_revision(revision_id)
        summary = 'New revision %d in %s' % (revno, url)
        body = 'Committer: %s\n' % revision.committer
        body += 'Date: %s\n' % format_date(revision.timestamp,
            revision.timezone)
        body += '\n'
        body += revision.message
        body = cgi.escape(body)
        nw = Notify.Notification.new(summary, body, None)
        def start_viz(notification=None, action=None, data=None):
            """Start the viz program."""
            from bzrlib.plugins.gtk.commands import start_viz_window
            pp = start_viz_window(branch, revision_id)
            pp.show()
        def start_branch(notification=None, action=None, data=None):
            """Start a Branch dialog"""
            from bzrlib.plugins.gtk.branch import BranchDialog
            bd = BranchDialog(remote_path=url)
            bd.run()
        if "actions" in Notify.get_server_caps():
            nw.add_action("inspect", "Inspect", start_viz, None)
            nw.add_action("branch", "Branch", start_branch, None)
        show_icon()
        GObject.timeout_add(5000, hide_icon)
        nw.set_timeout(5000)
        nw.show()
    except Exception, e:
        print e
        raise
bus.add_signal_receiver(catch_branch,
                        dbus_interface=BROADCAST_INTERFACE,
                        signal_name="Revision")
Notify.init("bzr-notify")

if sys.argv[-1] == 'test':
    # Exit before main loop.
    sys.exit(0)

Gtk.main()