This file is indexed.

/usr/share/pyshared/allmydata/web/reliability.py is in tahoe-lafs 1.9.2-1.

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
144
145
146
147
148
149
from nevow import rend, tags as T
reliability = None # might not be usable
try:
    from allmydata import reliability # requires NumPy
except ImportError:
    pass
from allmydata.web.common import getxmlfile, get_arg


DAY=24*60*60
MONTH=31*DAY
YEAR=365*DAY

def is_available():
    if reliability:
        return True
    return False

def yandm(seconds):
    return "%dy.%dm" % (int(seconds/YEAR), int( (seconds%YEAR)/MONTH))

class ReliabilityTool(rend.Page):
    addSlash = True
    docFactory = getxmlfile("reliability.xhtml")

    DEFAULT_PARAMETERS = [
        ("drive_lifetime", "8Y", "time",
         "Average drive lifetime"),
        ("k", 3, "int",
         "Minimum number of shares needed to recover the file"),
        ("R", 7, "int",
         "Repair threshold: repair will not occur until fewer than R shares "
         "are left"),
        ("N", 10, "int",
         "Total number of shares of the file generated"),
        ("delta", "1M", "time", "Amount of time between each simulation step"),
        ("check_period", "1M", "time",
         "How often to run the checker and repair if fewer than R shares"),
        ("report_period", "3M", "time",
         "Amount of time between result rows in this report"),
        ("report_span", "5Y", "time",
         "Total amount of time covered by this report"),
        ]

    def parse_time(self, s):
        if s.endswith("M"):
            return int(s[:-1]) * MONTH
        if s.endswith("Y"):
            return int(s[:-1]) * YEAR
        return int(s)

    def format_time(self, s):
        if s%YEAR == 0:
            return "%dY" % (s/YEAR)
        if s%MONTH == 0:
            return "%dM" % (s/MONTH)
        return "%d" % s

    def get_parameters(self, ctx):
        parameters = {}
        for (name,default,argtype,description) in self.DEFAULT_PARAMETERS:
            v = get_arg(ctx, name, default)
            if argtype == "time":
                value = self.parse_time(v)
            else:
                value = int(v)
            parameters[name] = value
        return parameters

    def renderHTTP(self, ctx):
        self.parameters = self.get_parameters(ctx)
        self.results = reliability.ReliabilityModel.run(**self.parameters)
        return rend.Page.renderHTTP(self, ctx)

    def make_input(self, name, old_value):
        return T.input(name=name, type="text", size="5",
                       value=self.format_time(old_value))

    def render_forms(self, ctx, data):
        f = T.form(action=".", method="get")
        table = []
        for (name,default_value,argtype,description) in self.DEFAULT_PARAMETERS:
            old_value = self.parameters[name]
            i = self.make_input(name, old_value)
            table.append(T.tr[T.td[name+":"], T.td[i], T.td[description]])
        go = T.input(type="submit", value="Recompute")
        return [T.h2["Simulation Parameters:"],
                f[T.table[table], go],
                ]

    def data_simulation_table(self, ctx, data):
        for row in self.results.samples:
            yield row

    def render_simulation_row(self, ctx, row):
        (when, unmaintained_shareprobs, maintained_shareprobs,
         P_repaired_last_check_period,
         cumulative_number_of_repairs,
         cumulative_number_of_new_shares,
         P_dead_unmaintained, P_dead_maintained) = row
        ctx.fillSlots("t", yandm(when))
        ctx.fillSlots("P_repair", "%.6f" % P_repaired_last_check_period)
        ctx.fillSlots("P_dead_unmaintained", "%.6g" % P_dead_unmaintained)
        ctx.fillSlots("P_dead_maintained", "%.6g" % P_dead_maintained)
        return ctx.tag

    def render_report_span(self, ctx, row):
        (when, unmaintained_shareprobs, maintained_shareprobs,
         P_repaired_last_check_period,
         cumulative_number_of_repairs,
         cumulative_number_of_new_shares,
         P_dead_unmaintained, P_dead_maintained) = self.results.samples[-1]
        return ctx.tag[yandm(when)]

    def render_P_loss_unmaintained(self, ctx, row):
        (when, unmaintained_shareprobs, maintained_shareprobs,
         P_repaired_last_check_period,
         cumulative_number_of_repairs,
         cumulative_number_of_new_shares,
         P_dead_unmaintained, P_dead_maintained) = self.results.samples[-1]
        return ctx.tag["%.6g (%1.8f%%)" % (P_dead_unmaintained,
                                           100*P_dead_unmaintained)]

    def render_P_loss_maintained(self, ctx, row):
        (when, unmaintained_shareprobs, maintained_shareprobs,
         P_repaired_last_check_period,
         cumulative_number_of_repairs,
         cumulative_number_of_new_shares,
         P_dead_unmaintained, P_dead_maintained) = self.results.samples[-1]
        return ctx.tag["%.6g (%1.8f%%)" % (P_dead_maintained,
                                           100*P_dead_maintained)]

    def render_P_repair_rate(self, ctx, row):
        (when, unmaintained_shareprobs, maintained_shareprobs,
         P_repaired_last_check_period,
         cumulative_number_of_repairs,
         cumulative_number_of_new_shares,
         P_dead_unmaintained, P_dead_maintained) = self.results.samples[-1]
        freq = when / cumulative_number_of_repairs
        return ctx.tag["%.6g" % freq]

    def render_P_repair_shares(self, ctx, row):
        (when, unmaintained_shareprobs, maintained_shareprobs,
         P_repaired_last_check_period,
         cumulative_number_of_repairs,
         cumulative_number_of_new_shares,
         P_dead_unmaintained, P_dead_maintained) = self.results.samples[-1]
        generated_shares = cumulative_number_of_new_shares / cumulative_number_of_repairs
        return ctx.tag["%1.2f" % generated_shares]