[moin-user] Uploading pages programmatically fails
PETER BLEACKLEY
pete.bleackley at btinternet.com
Mon Sep 4 02:51:35 EDT 2017
I'm trying to transcribe a podcast to my MoinMoin instance. The code I use to upload the transcribed text is a follows.
def upload(item,transcript):
"""Gets transcrpt from sphinx, and uploads to MoinMoin"""
link_url=None
for link in item.links:
if link['rel']=='alternate':
link_url=link['href']
print 'Reading',item['title'],'transcript from Sphinx'
try:
username='TranscriBot'
password=os.environ['CSW_PASSWORD']
wikiurl=u'http://sources.conlang.org'
wiki=xmlrpclib.ServerProxy(wikiurl+'?action=xmlrpc2',allow_none=True)
auth_token=wiki.getAuthToken(username,password)
mc=xmlrpclib.MultiCall(wiki)
mc.applyAuthToken(auth_token)
page=u"""#format creole
= {{title}}
==[[{url}|{title}]]\n
Published: {date} \\ \n
===Transcript\n
{transcript}\n
===Tags\n
{taglist}""".format(title=item['title'],
url=link_url,
date=item['published'],
transcript=transcript.read(),
taglist=u'\n'.join([u' # [[Conlangery Podcast]]']+[u' # [[{}]]'.format(tag['term'])
for tag in item['tags']]))
title=item['title'].replace('#','').replace(':','')
mc.putPage(u'Conlangery Podcast/{}'.format(title),page)
infile=codecs.open('Conlangery_Podcast.txt','r','utf-8')
index=infile.read()+' # [[Conlangery Podcast/{}]]\n'.format(title)
mc.putPage('Conlangery Podcast',index)
with codecs.open('Conlangery_Podcast.txt','w','utf-8') as ofile:
ofile.write(index)
for result in mc():
print result
except Exception as error:
with open('TranscriBot_Error.log','a') as logfile:
logfile.write(error.message+'\n')
TranscriBot has all the neccessary permissions, and is in a TrustedGroup that is exempt from my TextCha.
However, no pages have been written to my wiki. Nothing is printed out when mc() is called, and nothing is written to TranscriBot_Error.log either (unless it's a lot of blank lines).
Any idea what's wrong and how I can fix it?
Pete
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/moin-user/attachments/20170904/194994eb/attachment.html>
More information about the moin-user
mailing list