/usr/share/pyshared/jsb/lib/outputcache.py is in jsonbot 0.84.4-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 | # jsb/outputcache.py
#
#
## jsb imports
from persist import Persist
from jsb.utils.name import stripname
from datadir import getdatadir
from jsb.utils.timeutils import hourmin
## basic imports
import os
import logging
import time
## clear function
def clear(target):
""" clear target's outputcache. """
cache = Persist(getdatadir() + os.sep + 'run' + os.sep + 'outputcache' + os.sep + stripname(target))
try:
cache.data['msg'] = []
cache.save()
except KeyError: pass
return []
## add function
def add(target, txtlist):
""" add list of txt to target entry. """
logging.warn("outputcache - adding %s lines" % len(txtlist))
t = []
for item in txtlist:
t.append("[%s] %s" % (hourmin(time.time()), item))
cache = Persist(getdatadir() + os.sep + 'run' + os.sep + 'outputcache' + os.sep + stripname(target))
d = cache.data
if not d.has_key('msg'): d['msg'] = []
d['msg'].extend(t)
while len(d['msg']) > 10: d['msg'].pop(0)
cache.save()
## set function
def set(target, txtlist):
""" set target entry to list. """
cache = Persist(getdatadir() + os.sep + 'run' + os.sep + 'outputcache' + os.sep + stripname(target))
if not cache.data.has_key('msg'): cache.data['msg'] = []
cache.data['msg'] = txtlist
cache.save()
## get function
def get(target):
""" get output for target. """
logging.warn("get target is %s" % target)
cache = Persist(getdatadir() + os.sep + 'run' + os.sep + 'outputcache' + os.sep + stripname(target))
try:
result = cache.data['msg']
if result: return result
except KeyError: pass
return []
|