This file is indexed.

/usr/lib/gdesklets/display/TargetPlotter.py is in gdesklets 0.36.1-5+b1.

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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
from TargetCanvas import TargetCanvas
from utils.datatypes import *


#
# Class for plotting graphs.
#
class TargetPlotter(TargetCanvas):

    def __init__(self, name, parent):

        # history of plot values
        self.__history = []

        # colors
        self.__bgcolor = ""
        self.__color = "navy"

        # scale range, initial value
        self.__minscale = 0
        self.__maxscale = 100

        TargetCanvas.__init__(self, name, parent)

        self._register_property("value", TYPE_FLOAT,
                                self._setp_value, self._getp)
        self._register_property("bg-color", TYPE_STRING,
                                self._setp_bgcolor, self._getp)
        self._register_property("color", TYPE_STRING,
                                self._setp_color, self._getp)
        self._register_property("size", TYPE_INT,
                                self._setp, self._getp)
        self._setp("size", 50)
        self._register_property("scala", TYPE_INT,
                                self._setp, self._getp)
        self._setp("scala", 0)
        self._register_property("scala-color", TYPE_STRING,
                                self._setp, self._getp)
        self._setp("scala-color", "black")
        self._register_property("scala-font", TYPE_STRING,
                                self._setp, self._getp)
        self._setp("scala-font", "Sans")

        # scale-bidir: not only scale the upper bound, but also the lower one
        self._register_property("scale-bidir", TYPE_BOOL,
                                self._setp, self._getp)
        self._setp("scale-bidir", False)
        # scale-holdmax: keep the maximum 'all-time' scaling, not only
        # max(history)
        self._register_property("scale-holdmax", TYPE_BOOL,
                                self._setp, self._getp)
        self._setp("scale-holdmax", False)

        self._register_property("bars", TYPE_BOOL,
                                self._setp, self._getp)
        self._setp("bars", False)


    #
    # Plots the values from the history.
    #
    def __plot(self):

        bg, fg = self.__bgcolor, self.__color
        min_value = self.__minscale
        max_value = self.__maxscale
        size = self.get_prop("size")

        x = 0.0
        delta_x = 100.0 / (size - 1)

        if (bg):
            try:
                color, opacity = self.__parse_color(bg)
            except ValueError, exc:
                log(`exc`)
                return

            body = "<rect x=\"0\" y=\"0\" width=\"100\" height=\"100\" " \
                   "style=\"stroke:%s;stroke-opacity:%d%%;fill:%s;" \
                   "fill-opacity:%d%%\"/>" % (color, opacity, color, opacity)
        else:
            body = ""

        if (self.__history):
            if ((self.get_prop("scale-holdmax")) == False):
                # reset scale range to default:
                max_value = 100
                min_value = 0
            max_value = max(max_value, max(self.__history))
            if (self.get_prop("scale-bidir")):
                min_value = min(min_value, min(self.__history))
            self.__minscale = min_value
            self.__maxscale = max_value
            scale = 100.0 / (max_value - min_value)

            history_size = min(len(self.__history), size)
            x, y = x, self.__history[-history_size]

            if (self.get_prop("bars")):
                body += "<path d=\"M%f %f " % (x, 100 + min_value * scale)
                for y in self.__history[-history_size + 1:]:
                    y = 100 - (y - min_value) * scale
                    body += "L%(x)f %(y)f " % vars()
                    x += delta_x
                    body += "M%f %f " % (x, 100 + min_value * scale)
            else:
                body += "<path d=\"M%f %f " % (x, 100 - (y - min_value) * scale)
                x += delta_x
                for y in self.__history[-history_size + 1:]:
                    y = 100 - (y - min_value) * scale
                    body += "L%(x)f %(y)f " % vars()
                    x += delta_x
            try:
                color, opacity = self.__parse_color(fg)
            except ValueError, exc:
                log(`exc`)
                return
            body += "\" style=\"stroke:%s;opacity:%d%%;fill:none\"/>" % \
                     (color, opacity)

        # draw scala
        scala = self.get_prop("scala")
        if (scala):
            scala_color = self.get_prop("scala-color")
            scala_font = self.get_prop("scala-font")
            for i in range(0, max_value + 1, scala):
                body += "<text x=\"0\" y=\"%d\" font-family=\"%s\" " \
                        "font-size=\"%d\" fill=\"%s\">%d</text>" \
                        % (max_value - i, scala_font, 5, scala_color, i)

        gfx = "<svg>" + body + "</svg>"
        self.set_prop("graphics", gfx)



    def __parse_color(self, value):

        if ("#" in value and len(value) == 9):
            opacity = float(int(value[7:], 16) / 255.0) * 100
            return (value[:7], opacity)
        elif (value.isalnum()):
            return (value, 100)
        else:
            raise ValueError("%s is an invalid color." % `value`)



    def _setp_value(self, key, value):

        self.__history.append(value)
        self.__plot()
        if (len(self.__history) > self.get_prop("size")):
            self.__history.pop(0)
        self._setp(key, value)



    def _setp_bgcolor(self, key, value):

        self.__bgcolor = value
        self.__plot()
        self._setp(key, value)


    def _setp_color(self, key, value):

        self.__color = value
        self.__plot()
        self._setp(key, value)