This file is indexed.

/usr/lib/python3/dist-packages/autopilot/_debug.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
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
#
# Autopilot Functional Test Tool
# Copyright (C) 2014 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/>.
#

"""Support for debug profiles.

Debug profiles are used to attach various items of debug information to
a test result. Profiles are named, but the names are for human
consumption only, and have no other significance.

Each piece of debug information is also a fixture, so debug profiles are
fixtures of fixtures!

"""

from autopilot.content import follow_file
from autopilot._fixtures import FixtureWithDirectAddDetail


class CaseAddDetailToNormalAddDetailDecorator(object):

    """A decorator object to turn a FixtureWithDirectAddDetail object into
    an object that supports addDetail.
    """

    def __init__(self, decorated):
        self.decorated = decorated

    def addDetail(self, name, content):
        return self.decorated.caseAddDetail(name, content)

    def __repr__(self):
        return '<%s %r>' % (self.__class__.__name__, self.decorated)

    def __getattr__(self, name):
        return getattr(self.decorated, name)


class DebugProfile(FixtureWithDirectAddDetail):

    """A debug profile that contains manny debug objects."""

    name = ""

    def __init__(self, caseAddDetail, debug_fixtures=[]):
        """Create a debug profile.

        :param caseAddDetail: A closure over the testcase's addDetail
            method, or a similar substitution method.
        :param debug_fixtures: a list of fixture class objects, each one will
            be set up when this debug profile is used.
        """
        super(DebugProfile, self).__init__(caseAddDetail)
        self.debug_fixtures = debug_fixtures

    def setUp(self):
        super(DebugProfile, self).setUp()
        for FixtureClass in self.debug_fixtures:
            self.useFixture(FixtureClass(self.caseAddDetail))


class NormalDebugProfile(DebugProfile):

    name = "normal"

    def __init__(self, caseAddDetail):
        super(NormalDebugProfile, self).__init__(
            caseAddDetail,
            [
                SyslogDebugObject,
            ],
        )


class VerboseDebugProfile(DebugProfile):

    name = "verbose"

    def __init__(self, caseAddDetail):
        super(VerboseDebugProfile, self).__init__(
            caseAddDetail,
            [
                SyslogDebugObject,
            ],
        )


def get_default_debug_profile():
    return NormalDebugProfile


def get_all_debug_profiles():
    return {
        NormalDebugProfile,
        VerboseDebugProfile,
    }


class DebugObject(FixtureWithDirectAddDetail):

    """A single piece of debugging information."""


class LogFileDebugObject(DebugObject):

    """Monitors a log file on disk."""

    def __init__(self, caseAddDetail, log_path):
        """Create a debug object that will monitor the contents of a log
        file on disk.

        :param caseAddDetail: A closure over the testcase's addDetail
            method, or a similar substitution method.
        :param log_path: The path to monitor.
        """
        super(LogFileDebugObject, self).__init__(caseAddDetail)
        self.log_path = log_path

    def setUp(self):
        super(LogFileDebugObject, self).setUp()
        follow_file(
            self.log_path,
            CaseAddDetailToNormalAddDetailDecorator(self)
        )


def SyslogDebugObject(caseAddDetail):
    return LogFileDebugObject(caseAddDetail, "/var/log/syslog")