This file is indexed.

/usr/share/pyshared/gplugs/gcollect.py is in gozerbot 0.99.1-2.

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
# plugs/gcollect.py
#
#

""" run garbage collector """

__copyright__ = 'this file is in the public domain'

from gozerbot.periodical import periodical
from gozerbot.generic import rlog
from gozerbot.commands import cmnds
from gozerbot.examples import examples
from gozerbot.persist.persiststate import PlugState
from gozerbot.plughelp import plughelp
from gozerbot.tests import tests

import gc, time

plughelp.add('gcollect', 'help the garbage collector')

state = PlugState()
state.define('wait', 300)
state.define('enable', 0)

if state['enable']:
    gc.enable()
    rlog(10, 'gcollect', 'garbage collector enabled .. wait is %s' % state['wait'])

def shutdown():
    periodical.kill()

def gcollect():
    rlog(1, 'gcollect', 'running collector')
    gc.collect()
    time.sleep(5)
    gc.collect()
    time.sleep(5)
    gc.collect()

if state['enable']:
    pid = periodical.addjob(state['wait'], 0, gcollect)
else:
    pid = None

def handle_gcollectwait(bot, ievent):
    try:
        newwait = int(ievent.args[0])
    except (IndexError, ValueError):
        ievent.reply('gcollect wait is %s seconds' % state['wait'])
        return
    if newwait < 60:
        ievent.reply('min. number of seconds is 60')
        return
    state['wait'] = newwait
    state.save()
    if pid:
        periodical.changeinterval(pid, newwait)
    ievent.reply('gcollect wait set to %s' % state['wait'])

cmnds.add('gcollect-wait', handle_gcollectwait, 'OPER')
examples.add('gcollect-wait', 'set wait of garbage collector', \
'gcollect-wait 300')
tests.add('gcollect-wait 300')

def handle_gcollect(bot, ievent):
    gcollect()
    ievent.reply('collector runned')

cmnds.add('gcollect', handle_gcollect, 'OPER', threaded=True)
examples.add('gcollect', 'run garbage collector', 'gcollect')
tests.add('gcollect')

def handle_gcollectenable(bot, ievent):
    global pid
    state['enable'] = 1
    state.save()
    pid = periodical.addjob(state['wait'], 0, gcollect)
    ievent.reply('gcollect enabled')

cmnds.add('gcollect-enable', handle_gcollectenable, 'OPER')
examples.add('gcollect-enable', 'enable the garbage collector', 'gcollect-enable')
tests.add('gcollect-enable')

def handle_gcollectdisable(bot, ievent):
    state['enable'] = 0
    state.save()
    periodical.kill()
    ievent.reply('gcollect disabled')

cmnds.add('gcollect-disable', handle_gcollectdisable, 'OPER')
examples.add('gcollect-disable', 'disable the garbage collector', 'gcollect-disable')
tests.add('gcollect-disable')