http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11438
Revision: 11438 Author: drtrigon Date: 2013-04-23 15:14:51 +0000 (Tue, 23 Apr 2013) Log Message: ----------- bug fix; KeyError: 'caller_file' (adoption to pywikibot logger needed) improvement; command line parameter handling minor changes in logging header
Modified Paths: -------------- trunk/pywikipedia/subster.py trunk/pywikipedia/subster_irc.py trunk/pywikipedia/sum_disc.py trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/subster.py =================================================================== --- trunk/pywikipedia/subster.py 2013-04-23 08:35:20 UTC (rev 11437) +++ trunk/pywikipedia/subster.py 2013-04-23 15:14:51 UTC (rev 11438) @@ -443,7 +443,7 @@ external_data_dict = {param['value']: external_data[0]} else: external_data_dict = {param['value']: str(external_data)} - logging.getLogger('subster').debug( str(external_data_dict) ) + pywikibot.debug( str(external_data_dict) )
param['postproc'] = eval(param['postproc']) # should be secured as given below, but needs code changes in wiki too @@ -461,7 +461,7 @@ if func: exec(self._code + (self._bot_config['CodeTemplate'] % func), scope, scope) external_data = DATA[0] - logging.getLogger('subster').debug( external_data ) + pywikibot.debug( external_data )
# 5.) subst content (content, tags) = self.subTag(content, value, external_data, int(param['count'])) @@ -776,10 +776,9 @@ def main(): args = pywikibot.handleArgs() bot = SubsterBot() # for several user's, but what about complete automation (continous running...) - if len(args) > 0: - for arg in args: - pywikibot.showHelp() - return + for arg in args: + pywikibot.showHelp() + return try: bot.run() except KeyboardInterrupt:
Modified: trunk/pywikipedia/subster_irc.py =================================================================== --- trunk/pywikipedia/subster_irc.py 2013-04-23 08:35:20 UTC (rev 11437) +++ trunk/pywikipedia/subster_irc.py 2013-04-23 15:14:51 UTC (rev 11438) @@ -145,12 +145,22 @@ del bot
def main(): + args = pywikibot.handleArgs() subster.debug = debug site = pywikibot.getSite() site.forceLogin() chan = '#' + site.language() + '.' + site.family.name bot = SubsterTagModifiedBot(site, chan, site.loggedInAs(), "irc.wikimedia.org") - bot.start() + for arg in args: + pywikibot.showHelp() + return + try: + bot.start() + except KeyboardInterrupt: + pywikibot.output('\nQuitting program...')
if __name__ == "__main__": - main() + try: + main() + finally: + pywikibot.stopme()
Modified: trunk/pywikipedia/sum_disc.py =================================================================== --- trunk/pywikipedia/sum_disc.py 2013-04-23 08:35:20 UTC (rev 11437) +++ trunk/pywikipedia/sum_disc.py 2013-04-23 15:14:51 UTC (rev 11438) @@ -917,7 +917,7 @@ # skip to local disc page, since this is the only page the user should watch itself if (page.site().language() == localinterwiki) and \ (page.site().family.name == u'wikipedia'): - logging.getLogger('sum_disc').warning( + pywikibot.warning( u'skipping global wiki notify to local wiki %s' % page.title(asLink=True) ) continue @@ -1075,7 +1075,7 @@ try: self.append(page, text, comment=comment, minorEdit=minEd, force=True) except pywikibot.MaxTriesExceededError: - logging.getLogger('sum_disc').warning( + pywikibot.warning( u'Problem MaxTriesExceededError occurred, thus skipping this user!') return # skip history write else: @@ -1433,7 +1433,7 @@ #sections = page.getSections(minLevel=1, force=True) # slow for pages with > 100 sections sections = []
- logging.getLogger('sum_disc').warning( + pywikibot.warning( u'Problem resolving section data, processing the whole page at once...')
# drop from templates included headings (are None)
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2013-04-23 08:35:20 UTC (rev 11437) +++ trunk/pywikipedia/wikipedia.py 2013-04-23 15:14:51 UTC (rev 11438) @@ -9173,9 +9173,9 @@ # script call output(u'COMMAND: %s' % unicode(sys.argv))
- # new framework release/revision? + # new framework release/revision? (handleArgs needs to be called first) site = getSite() - output(u'VERSION: %s' % unicode((version.getversion().strip(' ()'), + output(u'VERSION: %s' % unicode((version.getversion().strip(), version.getversion_onlinerepo(), site.live_version())))