This file is indexed.

/usr/lib/python2.7/dist-packages/autopilot/vis/bus_enumerator.py is in python-autopilot-vis 1.4+14.04.20140416-0ubuntu1.

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

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
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
#
# Autopilot Functional Test Tool
# Copyright (C) 2013 Canonical
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

from collections import defaultdict

from autopilot.vis.dbus_search import _start_trawl

from PyQt4.QtCore import (
    pyqtSignal,
    QObject,
)


class BusEnumerator(QObject):
    """A simple utility class to support enumeration of all DBus connections,
    objects, and interfaces.

    Create an instance of ths class, and connect to the new_interface_found
    signal.

    """

    new_interface_found = pyqtSignal(str, str, str)

    def __init__(self, bus):
        super(BusEnumerator, self).__init__()
        self._bus = bus
        self._data = defaultdict(lambda: defaultdict(list))

    def get_found_connections(self):
        """Get a list of found connection names. This may not be up to date."""
        return list(self._data.keys())

    def get_found_objects(self, connection_string):
        """Get a list of found objects for a particular connection name.

        This may be out of date.

        """
        if connection_string not in self._data:
            raise KeyError("%s not in results" % connection_string)
        return list(self._data[connection_string].keys())

    def get_found_interfaces(self, connection_string, object_path):
        """Get a list of found interfaces for a particular connection name and
        object path.

        This may be out of date.

        """
        if connection_string not in self._data:
            raise KeyError("connection %s not in results" % connection_string)
        if object_path not in self._data[connection_string]:
            raise KeyError(
                "object %s not in results for connection %s" %
                (object_path, connection_string))
        return self._data[connection_string][object_path]

    def start_trawl(self):
        """Start trawling the bus for interfaces."""
        for connection in self._bus.list_names():
            _start_trawl(self._bus, connection, self._add_hit)

    def _add_hit(self, conn_name, obj_name, interface_name):
        self.new_interface_found.emit(conn_name, obj_name, interface_name)
        self._data[conn_name][obj_name].append(interface_name)