- This is a personal developmental wiki, it may often be in an unstable or experimental state and the lack of meaningful content on a page is often intentional; however, you can participate. Please: 1) create an account, 2) confirm your e-mail, 3) send Deirdre and e-mail telling her who you are and why you are interested. Thanks, --Deirdre(talk • contribs)
Difference between revisions of "Miszatest"
(testing) |
(No difference)
|
Revision as of 21:37, 3 December 2011
- !/usr/bin/env python
import sys, os sys.stderr = sys.stdout
import cgitb cgitb.enable()
from cgi import escape
print "Content-type: text/html" print
import urllib, re import monobook, misza
DST_PREFIX = 'Python:' UPDATE = u"""Template:Update
%(newdata)s
"""
def update(site, filename):
par = { 'site' : 'http://svn.wikimedia.org', 'module' : '/viewvc/pywikipedia/trunk/pywikipedia', 'file' : filename, } url = '%(site)s%(module)s/%(file)s?view=log' % par data = urllib.urlopen(url).read() rx = re.search(r'Revision <a href=".*?">(?P<rev>.+?)</a>.*?\(<a href="(?P<checkouturl>[^\s]*?)">download</a>\)',data,re.DOTALL) if rx: par['rev'] = rx.group('rev') par['checkouturl'] = rx.group('checkouturl') url = '%(site)s%(checkouturl)s' % par newdata = urllib.urlopen(url).read().decode('utf-8') par['newdata'] = newdata
pg = wikipedia.Page(site,DST_PREFIX+filename) try: oldtxt = pg.get() except: oldtxt = u
rx = re.search('
\n(?P<olddata>.*)\n
',oldtxt,re.DOTALL)
if rx and newdata==rx.group('olddata'): return False, 'No need to update.'
cmt = 'Update from SVN tree (%(rev)s)' % par pg.put(UPDATE % par,comment=cmt,minorEdit=False) return True, 'Updated successfully.' else: return False, 'File not found.'
if os.environ['QUERY_STRING'].startswith('file='):
filename = os.environ['QUERY_STRING'][5:]
else:
filename = None
print monobook.doc_start()
print monobook.head(u"Botwiki source updater")
content = u"""
Botwiki updater
This script updates source code on the <a href="http://botwiki.sno.cc/wiki/Main_Page">botwiki</a> with the latest SVN revision - just fill in the file name below:
<form action="botwikiupdate.py" method="GET">
<input name="file" id="file" type="text" value=\""""
if filename: content += filenamecontent += u"""" /> |
<input type="submit" /> |
</form> """
if filename:
try: os.chdir('/home/misza13/SVNbot') sys.path.append('/home/misza13/pywikipedia') print ""
content += '
\n<a href="http://botwiki.sno.cc/wiki/%s%s">%s</a>' % (DST_PREFIX,filename,reply)
finally: wikipedia.stopme() finally: pass
print monobook.body(
content = content, navigation = misza.navigation(), footer = misza.footer(), )
print monobook.doc_end()