http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11445
Revision: 11445 Author: drtrigon Date: 2013-04-24 12:32:58 +0000 (Wed, 24 Apr 2013) Log Message: ----------- improvement; adopted bot to latest logging output and header changes
Modified Paths: -------------- branches/rewrite/scripts/script_wui.py
Modified: branches/rewrite/scripts/script_wui.py =================================================================== --- branches/rewrite/scripts/script_wui.py 2013-04-24 12:31:07 UTC (rev 11444) +++ branches/rewrite/scripts/script_wui.py 2013-04-24 12:32:58 UTC (rev 11445) @@ -76,7 +76,6 @@
import pywikibot import pywikibot.botirc -from pywikibot import version
bot_config = { 'BotName': pywikibot.config.usernames[pywikibot.config.family][pywikibot.config.mylang], @@ -190,17 +189,13 @@ try: thread.start_new_thread( main_script, (self.refs[page_title], rev, params) ) except: - #pywikibot.output(u"WARNING: unable to start thread") - pywikibot.warning(u"Unable to start thread") - # (done according to subster in trunk and submit in rewrite/.../data/api.py) - #exc_info = sys.exc_info() - #tb = traceback.format_exception(exc_info[0], exc_info[1], exc_info[2]) - tb = traceback.format_exc() - pywikibot.error(tb) # secure traceback print (from api.py submit) - wiki_logger(tb, self.refs[page_title], rev) # TODO: is this error handling here needed at all??!? + pywikibot.exception(tb=True) # secure traceback print (from api.py submit) + pywikibot.warning(u"Unable to start thread")
+ wiki_logger(traceback.format_exc(), self.refs[page_title], rev) + # Define a function for the thread def main_script(page, rev=None, params=None): # http://opensourcehacker.com/2011/02/23/temporarily-capturing-python-logging-... @@ -284,7 +279,7 @@ __sys_argv = sys.argv
# verbosely output version info of all involved scripts - output_verinfo() + # PROBLEM: correct place -> improve logging!!
site = pywikibot.getSite() site.login() @@ -296,16 +291,6 @@ bot.t.cancel() raise
-def output_verinfo(): - # script call - pywikibot.output(u'SCRIPT CALL:') - pywikibot.output(u' ' + u' '.join(sys.argv)) - pywikibot.output(u'') - if __name__ == "__main__": -# # verbosely output version info of all involved scripts -# # PROBLEM: correct place, but output not logged here, thus moved to 'main()' -> improve logging!! (look e.g. at botirc.py) -# output_verinfo() - # run bot main()