This file is indexed.

/usr/share/pyshared/Eikazo/postprocessing/procinfo.py is in eikazo 0.5.2-8.

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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
"""
Copyright (c) Abel Deuring 2006 <adeuring@gmx.net>

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 2 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, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

collect information about available filter plugins

"""
import os, sys, traceback, time
import gtk
from Eikazo import I18n, Processor, Config

t = I18n.get_translation('eikazo')
if t:
    _ = t.gettext
else:
    _ = lambda x: x

N_ = lambda x: x

DEBUG = 1

# for the definition of the sort order
RGB=1
GRAY=2
BILEVEL=3

def outputinfo():
    """ return a list of known output classes
    """

# common processor class for filters
# - queue length is fixed to 1
# - if the filter is disabled, all methods call the
#   same method of the output resp. input
class ScanJobFilterProcessor(Processor.SaneThreadingQueueingProcessor):
    def __init__(self, paramsadm, input_producer, notify_hub,
                 filtername, enabled):
        """ input_producer, queue_length: see base classes
            paramsadm: instance of a class which can return
        """
        Processor.SaneThreadingQueueingProcessor.__init__(self, 
            input_producer, notify_hub, 1)
        self.errorjobs = []
        self.paramsadm = paramsadm
        self.start()
        self.status = 0
        self.filtername = filtername
        self.enabled = enabled
        
    def enable(self, v):
        self.enabled = v
    
    def append(self, job):
        if self.enabled:
            Processor.SaneThreadingQueueingProcessor.append(self, job)
            job.status[self.filtername] = _('queued by %s') % self.filtername
            job.owner = self
            self.notify('status changed', job)
        else:
            self.send_toOutput(job)
    
    def can_append(self, job):
        if self.enabled:
            return Processor.SaneThreadingQueueingProcessor.can_append(self, job)
        else:
            if self.output:
                res = [x.can_append(job) for x in self.output]
                return reduce(lambda x,y: x and y, res)
            else:
                return True
        
    def numjobs(self, cascade):
        self.queuelock.acquire()
        res = len(self.queue) + len(self.errorjobs)
        if self.status != 0:
            res += 1
        self.queuelock.release()
        return res

    def run(self):
        while not self.abort:
            if len(self.queue) and not self.errorjobs:
                self.queuelock.acquire()
                job = self.queue.pop(0)
                self.status = 1 # writing
                self.queuelock.release()
                job.set_active(True)
                try:
                    job.status[self.filtername] = _('processed by %s' % self.filtername)
                    self.notify('status changed', job)
                    self.paramsadm.filter(job)
                    del job.status[self.filtername]
                    self.send_toOutput(job)
                    if job.owner == self:
                        self.notify('removed', job)
                except:
                    job.error = sys.exc_info()
                    job.status[self.filtername] = _('filter error: %s' % self.filtername)
                    if DEBUG:
                        print str(job.error[0]), str(job.error[1])
                        traceback.print_tb(job.error[2])
                    self.notify('status changed', job)
                    self.errorjobs.append(job)
                job.set_active(False)
                self.status = 0 # idle
            else:
                time.sleep(0.1)
                


# base class for output providers

class ProcessingProvider(Config.ConfigAware):
    # derived classes must define these attributes:
    #   - name: Name of the output. Shown in a UI tab. (class attribute)
    #   - processor: A Processor.Processor instance
    #   - widget: The GUI widget for the processing provider
    #   - connectlabel: Text to show for the "enbale filter" checkbutton
    
    def __init__(self, notify_hub, enabled, config):
        Config.ConfigAware.__init__(self, config)
        
        self.processor_input = None
        self.enabled = enabled

        self.name_label = gtk.HBox()
        self.name_label_icon = gtk.Image()
        self.name_label_icon.set_from_stock(gtk.STOCK_CANCEL, 1)
        self.name_label.pack_start(self.name_label_icon, 
                                   expand=False, fill=True)
        self.name_label_icon.show()

        w = gtk.Label(_(self.name))
        self.name_label.pack_start(w, expand=False, fill=True)
        w.show()
        
        self.connect_widget = gtk.CheckButton(_(self.connectlabel))
        self.connect_widget.set_active(self.enabled)
        self.connect_widget.connect("toggled", self.cb_connect_widget)
        

    def cb_connect_widget(self, w):
        v = w.get_active()
        self.enable_filter(v)
    
    def get_widget(self):
        return self.widget
    
    def get_name(self):
        return self.name
    
    def get_name_label(self):
        return self.name_label
    
    def get_processor(self):
        return self.processor
        
    def get_connect_widget(self):
        return self.connect_widget
    
    def set_processor_input(self, input):
        self.processor_input = input
        self.processor.set_input(input)
    
    def enable_filter(self, v):
        if v != self.enabled:
            self.enabled = v
            self.connect_widget.set_active(v)
            self.processor.enable(v)
            if v:
                self.name_label_icon.set_from_stock(gtk.STOCK_OK, 1)
            else:
                self.name_label_icon.set_from_stock(gtk.STOCK_CANCEL, 1)
    
    def readConfig(self):
        val = self.config.getboolean('postprocessing', self.name + '-enable')
        if val != None:
            self.enable_filter(val)
    
    def writeConfig(self):
        self.config.set('postprocessing', self.name + '-enable', str(self.enabled))
    
def register():
    return [ScanToFile]