This file is indexed.

/usr/lib/python2.7/dist-packages/unity/emulators/__init__.py is in unity-autopilot 7.5.0+18.04.20180413-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
83
84
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2012 Canonical
# Author: Thomi Richards
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#

"""A collection of Unity-specific emulators."""

from time import sleep

from autopilot.introspection import (
    get_proxy_object_for_existing_process,
    ProcessSearchError
    )
from autopilot.introspection.dbus import CustomEmulatorBase
from autopilot.introspection.backends import DBusAddress

from dbus import DBusException

keys = {
        "Left/launcher/keynav/prev": "launcher/keynav/prev",
        "Left/launcher/keynav/next": "launcher/keynav/next",
        "Left/launcher/keynav/open-quicklist": "launcher/keynav/open-quicklist",
        "Bottom/launcher/keynav/prev": "launcher/keynav/close-quicklist",
        "Bottom/launcher/keynav/next": "launcher/keynav/open-quicklist",
        "Bottom/launcher/keynav/open-quicklist": "launcher/keynav/prev",
}
class UnityIntrospectionObject(CustomEmulatorBase):

    DBUS_SERVICE = "com.canonical.Unity"
    DBUS_OBJECT = "/com/canonical/Unity/Debug"

    _Backend = DBusAddress.SessionBus(DBUS_SERVICE, DBUS_OBJECT)

    def _repr_string(self, obj_details=""):
        geostr = ""
        if hasattr(self, 'globalRect'):
            geostr = " geo=[{r.x}x{r.y} {r.width}x{r.height}]".format(r=self.globalRect)

        obj_details.strip()
        obj_details = " "+obj_details if len(obj_details) else ""

        return "<{cls} {addr} id={id}{geo}{details}>".format(cls=self.__class__.__name__,
                                                             addr=hex(id(self)),
                                                             id=self.id,
                                                             geo=geostr,
                                                             details=obj_details)

    def __repr__(self):
        with self.no_automatic_refreshing():
            return self._repr_string()

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self.id == other.id

    def __ne__(self, other):
        return not self.__eq__(other)


def ensure_unity_is_running(timeout=300):
    """Poll the unity debug interface, and return when it's ready for use.

    The default timeout is 300 seconds (5 minutes) to account for the case where
    Unity has crashed and is taking a while to get restarted (on a slow VM for
    example).

    If, after the timeout period, unity is still not up, this function raises a
    RuntimeError exception.

    """
    sleep_period=10
    for i in range(0, timeout, sleep_period):
        try:
            get_proxy_object_for_existing_process(
                connection_name=UnityIntrospectionObject.DBUS_SERVICE,
                object_path=UnityIntrospectionObject.DBUS_OBJECT
            )
            return True
        except ProcessSearchError:
            sleep(sleep_period)
    raise RuntimeError("Unity debug interface is down after %d seconds of polling." % (timeout))