http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10874
Revision: 10874 Author: drtrigon Date: 2013-01-05 20:21:39 +0000 (Sat, 05 Jan 2013) Log Message: ----------- bug fix; namespace scope for exceptions changed improvement; replaced function gettraceback with module traceback (reverted parts of r10763) improvement; logs docu
Modified Paths: -------------- trunk/pywikipedia/logs/README trunk/pywikipedia/pywikibot/exceptions.py trunk/pywikipedia/subster.py trunk/pywikipedia/sum_disc.py
Modified: trunk/pywikipedia/logs/README =================================================================== --- trunk/pywikipedia/logs/README 2013-01-04 14:22:17 UTC (rev 10873) +++ trunk/pywikipedia/logs/README 2013-01-05 20:21:39 UTC (rev 10874) @@ -1,2 +1,5 @@ Bots can log their data here. It is used by interwiki.py and some bots will log here if used with the -log parameter. +If you run the bot from e.g. a server (like TS, labs, ...) it could be a good +idea to symlink this directory to your webspace public_html directory, e.g. +"cd public_html; ln -s [path-to]/logs trunk-logs".
Modified: trunk/pywikipedia/pywikibot/exceptions.py =================================================================== --- trunk/pywikipedia/pywikibot/exceptions.py 2013-01-04 14:22:17 UTC (rev 10873) +++ trunk/pywikipedia/pywikibot/exceptions.py 2013-01-05 20:21:39 UTC (rev 10874) @@ -10,9 +10,6 @@ __version__ = '$Id$'
-# Standard library imports -import traceback, StringIO - # Application specific imports import config
@@ -124,17 +121,3 @@ """ class UserActionRefuse(Error): pass - - -# @remarks need for Bot Error Handling; get the error tracebacks without -# raising the error -def gettraceback(exc_info): - output = StringIO.StringIO() - traceback.print_exception(exc_info[0], exc_info[1], exc_info[2], file=output) - - exception_only = traceback.format_exception_only(exc_info[0], exc_info[1]) - - result = output.getvalue() - output.close() - - return (exception_only, result)
Modified: trunk/pywikipedia/subster.py =================================================================== --- trunk/pywikipedia/subster.py 2013-01-04 14:22:17 UTC (rev 10873) +++ trunk/pywikipedia/subster.py 2013-01-05 20:21:39 UTC (rev 10874) @@ -65,15 +65,14 @@ #
-import re, sys, os, string, time -import difflib +import re, sys, os, string, time, copy +import difflib, traceback import BeautifulSoup import StringIO, zipfile, csv, urllib import mailbox, mimetypes, datetime, email.utils import openpyxl.reader.excel import crontab import logging -import copy import ast
import pagegenerators, basic @@ -272,7 +271,7 @@ substed_tags += tags except: exc_info = sys.exc_info() - (exception_only, result) = pywikibot.gettraceback(exc_info) + result = u''.join(traceback.format_exception(exc_info[0], exc_info[1], exc_info[2])) substed_content += ast.literal_eval(self._param_default['error']) %\ {'error': bot_config['ErrorTemplate'] %\ ( pywikibot.Timestamp.now().isoformat(' '), @@ -289,7 +288,7 @@ substed_tags += tags except: exc_info = sys.exc_info() - (exception_only, result) = pywikibot.gettraceback(exc_info) + result = u''.join(traceback.format_exception(exc_info[0], exc_info[1], exc_info[2])) substed_content += ast.literal_eval(item['error']) %\ {'error': bot_config['ErrorTemplate'] %\ ( item['value'],
Modified: trunk/pywikipedia/sum_disc.py =================================================================== --- trunk/pywikipedia/sum_disc.py 2013-01-04 14:22:17 UTC (rev 10873) +++ trunk/pywikipedia/sum_disc.py 2013-01-05 20:21:39 UTC (rev 10874) @@ -999,7 +999,7 @@ page = pywikibot.Page(self.site(), data[u'link']) page.globalwikinotify = data yield (page, data) - except pywikibot.exceptions.NoPage, e: + except pywikibot.NoPage, e: pywikibot.output(u'%s' %e)
## @since 10332 @@ -1159,7 +1159,7 @@ for name in hist.keys(): try: page = pywikibot.Page(self.site, name) - except pywikibot.exceptions.NoPage, e: + except pywikibot.NoPage, e: pywikibot.output(u'%s' %e) del hist[name] continue
pywikipedia-svn@lists.wikimedia.org