/usr/share/pyshared/MoinMoin/action/pollsistersites.py is in python-moinmoin 1.9.3-1ubuntu2.
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 | # -*- coding: iso-8859-1 -*-
"""
MoinMoin - "pollsistersites" action
This action fetches lists of page urls and page names from sister sites,
so we can implement SisterWiki functionality.
See: http://usemod.com/cgi-bin/mb.pl?SisterSitesImplementationGuide
@copyright: 2007 MoinMoin:ThomasWaldmann
@license: GNU GPL, see COPYING for details.
"""
import time, urllib
from MoinMoin import caching
from MoinMoin.util import timefuncs
def execute(pagename, request):
status = []
for sistername, sisterurl in request.cfg.sistersites:
arena = 'sisters'
key = sistername
cache = caching.CacheEntry(request, arena, key, scope='farm', use_pickle=True)
if cache.exists():
data = cache.content()
else:
data = {'lastmod': ''}
uo = urllib.URLopener()
uo.version = 'MoinMoin SisterPage list fetcher 1.0'
lastmod = data['lastmod']
if lastmod:
uo.addheader('If-Modified-Since', lastmod)
try:
sisterpages = {}
f = uo.open(sisterurl)
for line in f:
line = line.strip()
try:
page_url, page_name = line.split(' ', 1)
sisterpages[page_name.decode('utf-8')] = page_url
except:
pass # ignore invalid lines
try:
lastmod = f.info()["Last-Modified"]
except:
lastmod = timefuncs.formathttpdate(time.time())
f.close()
data['lastmod'] = lastmod
data['sisterpages'] = sisterpages
cache.update(data)
status.append(u"Site: %s Status: Updated. Pages: %d" % (sistername, len(sisterpages)))
except IOError, (title, code, msg, headers): # code e.g. 304
status.append(u"Site: %s Status: Not updated." % sistername)
except TypeError: # catch bug in python 2.5: "EnvironmentError expected at most 3 arguments, got 4"
status.append(u"Site: %s Status: Not updated." % sistername)
request.mimetype = 'text/plain'
request.write("\r\n".join(status).encode("utf-8"))
|