This file is indexed.

/usr/lib/python3/dist-packages/autopilot/display/_upa.py is in python3-autopilot 1.5.1+16.04.20160412-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
85
86
87
88
89
90
91
92
93
94
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
#
# Autopilot Functional Test Tool
# Copyright (C) 2012-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 autopilot.display import Display as DisplayBase
from autopilot.platform import image_codename
import subprocess


def query_resolution():
    try:
        return _get_fbset_resolution()
    except Exception:
        return _get_hardcoded_resolution()


def _get_fbset_resolution():
    """Return the resolution, as determined by fbset, or None."""
    fbset_output = _get_fbset_output()
    for line in fbset_output.split('\n'):
        line = line.strip()
        if line.startswith('Mode'):
            quoted_resolution = line.split()[1]
            resolution_string = quoted_resolution.strip('"')
            return tuple(int(piece) for piece in resolution_string.split('x'))
    raise RuntimeError("No modes found from fbset output")


def _get_fbset_output():
    return subprocess.check_output(["fbset", "-s", "-x"]).decode().strip()


def _get_hardcoded_resolution():
    name = image_codename()

    resolutions = {
        "generic": (480, 800),
        "mako": (768, 1280),
        "maguro": (720, 1280),
        "manta": (2560, 1600),
        "grouper": (800, 1280),
    }

    if name not in resolutions:
        raise NotImplementedError(
            'Device "{}" is not supported by Autopilot.'.format(name))

    return resolutions[name]


class Display(DisplayBase):
    """The base class/inteface for the display devices"""

    def __init__(self):
        super(Display, self).__init__()
        self._X, self._Y = query_resolution()

    def get_num_screens(self):
        """Get the number of screens attached to the PC."""
        return 1

    def get_primary_screen(self):
        """Returns an integer of which screen is considered the primary"""
        return 0

    def get_screen_width(self):
        return self._X

    def get_screen_height(self):
        return self._Y

    def get_screen_geometry(self, screen_number):
        """Get the geometry for a particular screen.

        :return: Tuple containing (x, y, width, height).

        """
        return (0, 0, self._X, self._Y)