lists.wikimedia.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
List overview
Download
Pywikipedia-svn
April 2013
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
pywikipedia-svn@lists.wikimedia.org
9 participants
175 discussions
Start a n
N
ew thread
SVN: [11456] trunk/pywikipedia/pwb.py
by drtrigon@svn.wikimedia.org
25 Apr '13
25 Apr '13
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11456
Revision: 11456 Author: drtrigon Date: 2013-04-25 14:48:10 +0000 (Thu, 25 Apr 2013) Log Message: ----------- new feature; added wrapper for server and unobserved execution (from rewrite) Added Paths: ----------- trunk/pywikipedia/pwb.py Added: trunk/pywikipedia/pwb.py =================================================================== --- trunk/pywikipedia/pwb.py (rev 0) +++ trunk/pywikipedia/pwb.py 2013-04-25 14:48:10 UTC (rev 11456) @@ -0,0 +1,195 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +#$ -m as +#$ -j y +#$ -b y +# SGE integration/interaction:
https://wiki.toolserver.org/view/Job_scheduling
+# Tip from Merlissimo: use (a=reschedule or abort, s= suspended) to send mail +# by SGE and exitcode 99 to restart the job and 100 to stop it in error state. +"""Wrapper script to use trunk in 'server' mode as cronjob - run scripts using +python bot_control.py <name_of_script> <options> + +and it will start logging, care about error reporting by mail and SGE. +It will also catch all output to stdout and stderr and report those incidents. +(compare to rewrite/pwb.py) +""" +## @package bot_control +# @brief General DrTrigonBot Robot(s) Wrapper (see rewrite/pwb.py too) +# +# @copyright Dr. Trigon, 2008-2013 +# +# @todo look also at and learn from daemonize.py (@ref daemonize) +# +# @section FRAMEWORK +# +# Python wikipedia robot framework, DrTrigonBot. +# @see
http://pywikipediabot.sourceforge.net/
+# @see
http://de.wikipedia.org/wiki/Benutzer:DrTrigonBot
+# +# @section LICENSE +# +# Distributed under the terms of the MIT license. +# @see
http://de.wikipedia.org/wiki/MIT-Lizenz
+# +# @section Usage +# @li Run any bot on server (according to rewrite/pwb.py): +# @verbatim python bot_control.py <name_of_script> <options> @endverbatim +# +__version__ = '$Id$' +# + + +import sys, os, traceback, shelve + +# wikipedia-bot imports +import userlib +# Splitting the bot into library parts +import wikipedia as pywikibot +from pywikibot import version # JIRA: DRTRIGON-131 + + +## Server Error Handling; send mail to user in case of error +# +# @todo consider solving/doing this with a logging handler like SMTPHandler +# +def send_mailnotification(text, subject): + username = pywikibot.config.usernames[pywikibot.config.family][pywikibot.config.mylang] + pos = username.lower().find('bot') + username = username[:pos] if (pos > 0) else username + + pywikibot.output(u'Sending mail "%s" to "%s" as notification!' % (subject, username)) + # JIRA: DRTRIGON-87; output even more debug info (tip by: valhallasw(a)arctus.nl) + site = pywikibot.getSite() + pywikibot.output(u'Bot allowed to send email: %r' % (site.isAllowed('sendemail'),)) + pywikibot.output(u'Permissions: %r' % (site._rights,)) + if not site.isAllowed('sendemail'): + pywikibot.output(u'Try getting new token: %r' % (site.getToken(getagain=True),)) + usr = userlib.User(site, username) + try: + if usr.sendMail(subject=subject, text=text): # 'text' should be unicode! + return + except: # break exception handling recursion + pywikibot.exception(tb=True) + pywikibot.error(u'mail to %s could not be sent!' % username) + + pywikibot.output(u'May be not logged in - try to send emergency email') + try: + import smtplib + from email.mime.text import MIMEText + # sender's and recipient's email addresses + FROM = "%s(a)toolserver.org" % username.lower() + TO = [FROM] # must be a list + # Create a text/plain message + msg = MIMEText(text) + msg['Subject'] = "!EMERGENCY! " + subject + msg['From'] = FROM + msg['To'] = ", ".join(TO) + # Send the mail + server = smtplib.SMTP("localhost") + server.sendmail(FROM, TO, msg.as_string()) + server.quit() + except: # break exception handling recursion + pywikibot.exception(tb=True) + pywikibot.error(u'emergency mail to %s could not be sent!' % TO) + + +## Bot Output Redirecting And Logging; to assure all output is logged +# +# @todo consider using 'rrdtool' to improve logging (and logging_statistics as +# well as creating graphs in panel.py - may be with 'bottle' as webserver) +# @see
http://segfault.in/2010/03/python-rrdtool-tutorial/
+# +class BotLoggerObject: + def __init__(self, layer='stdout'): + self._layer = layer + def write(self, string): + for line in string.strip().splitlines(): + pywikibot.critical('[%s] %s' % (self._layer, line)) + def close(self): + pass + def flush(self): + pass + + +# SGE: exit errorlevel +ERROR_SGE_ok = 0 # successful termination, nothing more to do +ERROR_SGE_stop = 1 # error, but not for SGE +ERROR_SGE_restart = 99 # restart the job +ERROR_SGE_lock = 100 # stop in error state (prevents re-starts) + +exitcode = ERROR_SGE_stop # action in error case (stop with error) +#exitcode = ERROR_SGE_restart # -------- " --------- (restart) +#exitcode = ERROR_SGE_lock # -------- " --------- (stop and lock) + + +if len(sys.argv) < 2: + raise RuntimeError("Not enough arguments defined.") +else: + logname = pywikibot.config.datafilepath('logs', '%s.log') + logfile = logname % ''.join([os.path.basename(sys.argv[0])]+sys.argv[1:]) + + arg = pywikibot.handleArgs() # '-family' and '-lang' have to be known for log-header + sys.stdout = BotLoggerObject(layer='stdout') # handle stdout + sys.stderr = BotLoggerObject(layer='stderr') # handle stderr + if not pywikibot.simulate: # suppress console output + pywikibot.ui.stdout = open(os.devnull, 'w') # + pywikibot.ui.stderr = open(os.devnull, 'w') # + #pywikibot._outputOld = lambda text, **kwargs: None # + # may be use "log = ['*']" in 'user-config.py' instead + pywikibot.setLogfileStatus(True, logfile, header=True) # set '-log' to catch all + # check:
http://de.wikipedia.org/wiki/Hilfe:MediaWiki/Versionen
+ + path = os.path.split(sys.argv[0])[0] + cmd = sys.argv.pop(1) + cmd = cmd.lstrip(u'-') + if u'.py' not in cmd.lower(): + cmd += u'.py' + sys.argv[0] = os.path.join(path, cmd) + bot_name = os.path.splitext(os.path.basename(sys.argv[0]))[0] + + error = u'' + try: + __release_ver = str(version.getversion_svn(pywikibot.config.datafilepath('..'))[1]) + #__release_ver = version.getversion().strip() + d = shelve.open(pywikibot.config.datafilepath('cache', 'state_bots')) + d['bot_control'] = { 'release_ver': __release_ver, + 'framework_ver': __release_ver, + 'online_ver': version.getversion_onlinerepo(), + } + pywikibot.output(d['bot_control']) + pywikibot.output(u'=== ' * 14) + d.close() + + sys.path.append(os.path.split(sys.argv[0])[0]) + execfile(sys.argv[0]) + + exitcode = ERROR_SGE_ok + pywikibot.output(u'') + pywikibot.output(u'DONE') + except: + pywikibot.exception(tb=True) + error = traceback.format_exc() + if pywikibot.logger.isEnabledFor(pywikibot.DEBUG): + exitcode = ERROR_SGE_ok # print traceback of re-raised errors by skipping sys.exit() + raise + else: + send_mailnotification(error, u'Bot ERROR') + pywikibot.output(u'') + pywikibot.warning(u'DONE with Exception(s) occured in Bot') + finally: + site = pywikibot.getSite() + name = str('%s-%s-%s' % (bot_name, site.family.name, site.lang)) + d = shelve.open(pywikibot.config.datafilepath('cache', 'state_bots')) + d[name] = {'error': str(bool(error)), + 'traceback': str(error.encode('utf-8')), + 'timestamp': str(pywikibot.Timestamp.now().isoformat(' ')), + } + d.close() + + pywikibot.stopme() + (sys.stdout, sys.stderr) = (sys.__stdout__, sys.__stderr__) + + # use exitcode to control SGE (restart or stop with sending mail) + # re-raised errors occouring in 'except' clause are skipped because + # of raised 'SystemExit' exception by sys.exit() + sys.exit(exitcode) Property changes on: trunk/pywikipedia/pwb.py ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Id Added: svn:eol-style + native
1
0
0
0
SVN: [11455] trunk/pywikipedia/family.py
by amir@svn.wikimedia.org
25 Apr '13
25 Apr '13
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11455
Revision: 11455 Author: amir Date: 2013-04-25 13:43:07 +0000 (Thu, 25 Apr 2013) Log Message: ----------- adding fa for 828 and 829 NSs Modified Paths: -------------- trunk/pywikipedia/family.py Modified: trunk/pywikipedia/family.py =================================================================== --- trunk/pywikipedia/family.py 2013-04-25 12:38:00 UTC (rev 11454) +++ trunk/pywikipedia/family.py 2013-04-25 13:43:07 UTC (rev 11455) @@ -4457,6 +4457,7 @@ 'de': u'Modul', 'dsb': u'Modul', 'eo': u'Modulo', + 'fa': u'پودمان', 'frr': u'Modul', 'gag': u'Modül', 'gan': u'模組', @@ -4493,6 +4494,7 @@ 'de': u'Modul Diskussion', 'dsb': u'Modul diskusija', 'eo': u'Modulo-Diskuto', + 'fa': u'بحث پودمان', 'ff': u'Discussion module', 'fr': u'Discussion module', 'frp': u'Discussion module',
1
0
0
0
SVN: [11454] branches/rewrite
by drtrigon@svn.wikimedia.org
25 Apr '13
25 Apr '13
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11454
Revision: 11454 Author: drtrigon Date: 2013-04-25 12:38:00 +0000 (Thu, 25 Apr 2013) Log Message: ----------- improvement; as follow-up to r11449 more externals and final merge with DrTrigonBot framework Modified Paths: -------------- branches/rewrite/externals/README branches/rewrite/pwb.py branches/rewrite/scripts/script_wui.py Modified: branches/rewrite/externals/README =================================================================== --- branches/rewrite/externals/README 2013-04-25 12:34:16 UTC (rev 11453) +++ branches/rewrite/externals/README 2013-04-25 12:38:00 UTC (rev 11454) @@ -18,6 +18,9 @@ (from
http://labix.org/lunatic-python
) Download the zip archive and unpack the 'lunatic-python-1.0' dir into the path 'externals/_lua' afterwards. + $ wget
http://labix.org/download/lunatic-python/lunatic-python-1.0.tar.bz2
+ $ tar -xvf lunatic-python-1.0.tar.bz2 + $ mv lunatic-python-1.0 _lua Patch package dir in order to work with newer lua (>= 5.1) versions $ patch -p1 -d [path-to-install-dir]/_lua < [path-to-externals]/patch-lua and you are done. Modified: branches/rewrite/pwb.py =================================================================== --- branches/rewrite/pwb.py 2013-04-25 12:34:16 UTC (rev 11453) +++ branches/rewrite/pwb.py 2013-04-25 12:38:00 UTC (rev 11454) @@ -19,10 +19,15 @@ if sys.version_info[1] < 6: raise RuntimeError("ERROR: Pywikipediabot only runs under Python 2.6 or higher") -sys.path.append('.') -sys.path.append('externals/httplib2') -sys.path.append('pywikibot/compat') +rewrite_path = os.path.dirname(sys.argv[0]) +if not os.path.isabs(rewrite_path): + rewrite_path = os.path.abspath(os.path.join(os.curdir, rewrite_path)) +sys.path.append(rewrite_path) +sys.path.append(os.path.join(rewrite_path, 'externals/httplib2')) +sys.path.append(os.path.join(rewrite_path, 'pywikibot/compat')) +sys.path.append(os.path.join(rewrite_path, 'externals')) + if "PYWIKIBOT2_DIR" not in os.environ: os.environ["PYWIKIBOT2_DIR"] = os.path.split(__file__)[0] Modified: branches/rewrite/scripts/script_wui.py =================================================================== --- branches/rewrite/scripts/script_wui.py 2013-04-25 12:34:16 UTC (rev 11453) +++ branches/rewrite/scripts/script_wui.py 2013-04-25 12:38:00 UTC (rev 11454) @@ -57,8 +57,6 @@ # --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- # __version__ = '$Id$' -__framework_rev__ = '11448' # check:
http://de.wikipedia.org/wiki/Hilfe:MediaWiki/Versionen
-__release_ver__ = '1.5.%s' # increase minor (1.x) at re-merges with framework # @@ -77,7 +75,6 @@ import pywikibot import pywikibot.botirc -from pywikibot import version bot_config = { 'BotName': pywikibot.config.usernames[pywikibot.config.family][pywikibot.config.mylang], @@ -230,10 +227,7 @@ exec( code ) except: # (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) + pywikibot.exception(tb=True) # secure traceback print (from api.py submit) sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ @@ -271,7 +265,7 @@ # comment = pywikibot.translate(self.site.lang, bot_config['msg'])) def main(): - global __simulate, __sys_argv, __release_ver__ + global __simulate, __sys_argv for arg in pywikibot.handleArgs(): pywikibot.showHelp('script_wui') @@ -280,15 +274,6 @@ __simulate = pywikibot.config.simulate __sys_argv = sys.argv - # output version info - __release_ver__ %= version.getversion_svn(pywikibot.config.datafilepath('..'))[1] - pywikibot.output({'release_ver': __release_ver__, - 'framework_ver': __framework_rev__, - 'release_online_ver': version.getversion_onlinerepo('
http://svn.toolserver.org/svnroot/drtrigon/
'), - 'framework_online_ver': version.getversion_onlinerepo(), - }) - pywikibot.output(u'=== ' * 14) - site = pywikibot.getSite() site.login() chan = '#' + site.language() + '.' + site.family.name
1
0
0
0
SVN: [11453] branches/rewrite/pywikibot/bot.py
by drtrigon@svn.wikimedia.org
25 Apr '13
25 Apr '13
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11453
Revision: 11453 Author: drtrigon Date: 2013-04-25 12:34:16 +0000 (Thu, 25 Apr 2013) Log Message: ----------- undo r11451 Modified Paths: -------------- branches/rewrite/pywikibot/bot.py Modified: branches/rewrite/pywikibot/bot.py =================================================================== --- branches/rewrite/pywikibot/bot.py 2013-04-25 12:05:05 UTC (rev 11452) +++ branches/rewrite/pywikibot/bot.py 2013-04-25 12:34:16 UTC (rev 11453) @@ -226,8 +226,7 @@ debuglogger.setLevel(DEBUG) debuglogger.addHandler(file_handler) - if not _handlers_initialized: - writelogheader() + writelogheader() _handlers_initialized = True
1
0
0
0
SVN: [11452] trunk/pywikipedia/weblinkchecker.py
by amir@svn.wikimedia.org
25 Apr '13
25 Apr '13
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11452
Revision: 11452 Author: amir Date: 2013-04-25 12:05:05 +0000 (Thu, 25 Apr 2013) Log Message: ----------- fixing bug #3611761 caused by r11440 Modified Paths: -------------- trunk/pywikipedia/weblinkchecker.py Modified: trunk/pywikipedia/weblinkchecker.py =================================================================== --- trunk/pywikipedia/weblinkchecker.py 2013-04-25 09:12:54 UTC (rev 11451) +++ trunk/pywikipedia/weblinkchecker.py 2013-04-25 12:05:05 UTC (rev 11452) @@ -155,8 +155,10 @@ # Also remove text inside nowiki links etc. text = pywikibot.removeDisabledParts(text) for m in linkR.finditer(text): - yield m.group('url') - + if m.group('url'): + yield m.group('url') + else: + yield m.group('urlb') class InternetArchiveConsulter: def __init__(self, url): self.url = url
1
0
0
0
SVN: [11451] branches/rewrite/pywikibot/bot.py
by drtrigon@svn.wikimedia.org
25 Apr '13
25 Apr '13
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11451
Revision: 11451 Author: drtrigon Date: 2013-04-25 09:12:54 +0000 (Thu, 25 Apr 2013) Log Message: ----------- bug fix; logging header output came too often Modified Paths: -------------- branches/rewrite/pywikibot/bot.py Modified: branches/rewrite/pywikibot/bot.py =================================================================== --- branches/rewrite/pywikibot/bot.py 2013-04-25 09:11:13 UTC (rev 11450) +++ branches/rewrite/pywikibot/bot.py 2013-04-25 09:12:54 UTC (rev 11451) @@ -226,7 +226,8 @@ debuglogger.setLevel(DEBUG) debuglogger.addHandler(file_handler) - writelogheader() + if not _handlers_initialized: + writelogheader() _handlers_initialized = True
1
0
0
0
SVN: [11450] branches/rewrite/scripts/clean_sandbox.py
by drtrigon@svn.wikimedia.org
25 Apr '13
25 Apr '13
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11450
Revision: 11450 Author: drtrigon Date: 2013-04-25 09:11:13 +0000 (Thu, 25 Apr 2013) Log Message: ----------- bug fix; AttributeError: 'module' object has no attribute 'translate' (follow-up to r11429) Modified Paths: -------------- branches/rewrite/scripts/clean_sandbox.py Modified: branches/rewrite/scripts/clean_sandbox.py =================================================================== --- branches/rewrite/scripts/clean_sandbox.py 2013-04-25 08:29:15 UTC (rev 11449) +++ branches/rewrite/scripts/clean_sandbox.py 2013-04-25 09:11:13 UTC (rev 11450) @@ -144,9 +144,9 @@ self.site = pywikibot.Site() self.site.login() if self.getOption('user'): - localSandboxTitle = pywikibot.translate(self.site, - user_sandboxTemplate, - fallback=False) + localSandboxTitle = i18n.translate(self.site, + user_sandboxTemplate, + fallback=False) localSandbox = pywikibot.Page(self.site, localSandboxTitle) content.update(user_content) sandboxTitle[self.site.lang] = [item.title() \ @@ -164,8 +164,8 @@ while True: wait = False now = time.strftime("%d %b %Y %H:%M:%S (UTC)", time.gmtime()) - localSandboxTitle = pywikibot.translate(self.site, sandboxTitle, - fallback=False) + localSandboxTitle = i18n.translate(self.site, sandboxTitle, + fallback=False) if type(localSandboxTitle) is list: titles = localSandboxTitle else: @@ -175,8 +175,8 @@ pywikibot.output(u'Preparing to process sandbox page %s' % sandboxPage.title(asLink=True)) try: text = sandboxPage.get() - translatedContent = pywikibot.translate(self.site, content, - fallback=False) + translatedContent = i18n.translate(self.site, content, + fallback=False) translatedMsg = i18n.twtranslate(self.site, 'clean_sandbox-cleaned') subst = 'subst:' in translatedContent
1
0
0
0
SVN: [11449] branches/rewrite
by drtrigon@svn.wikimedia.org
25 Apr '13
25 Apr '13
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11449
Revision: 11449 Author: drtrigon Date: 2013-04-25 08:29:15 +0000 (Thu, 25 Apr 2013) Log Message: ----------- new features; +2 thirdparty modules for externals (crontab, lunatic) Modified Paths: -------------- branches/rewrite/README branches/rewrite/externals/README branches/rewrite/scripts/script_wui.py Added Paths: ----------- branches/rewrite/externals/patch-lua Modified: branches/rewrite/README =================================================================== --- branches/rewrite/README 2013-04-24 17:30:40 UTC (rev 11448) +++ branches/rewrite/README 2013-04-25 08:29:15 UTC (rev 11449) @@ -2,5 +2,5 @@ improvements, such as full API usage and a pythonic package layout. If you want to run the rewrite as a stand-alone package, please also download the -pywikipedia-rewrite.externals package below, and place it's contents in the -externals/ subdirectory. +the contents of the externals/ subdirectory. Confer externals/README for more +information. Modified: branches/rewrite/externals/README =================================================================== --- branches/rewrite/externals/README 2013-04-24 17:30:40 UTC (rev 11448) +++ branches/rewrite/externals/README 2013-04-25 08:29:15 UTC (rev 11449) @@ -1,3 +1,25 @@ External dependencies for the rewrite branch. This package is only necessary to run pywikibot from a fully self-sufficient (no other dependencies other than -python 2.6+) directory. This is especially useful on Windows. +python 2.6+) directory. This is especially useful on Windows. + +Usually - under normal circumstances - these packages should be installed +separately elsewhere in the OS by the standard package managing system. + +If you want to run the rewrite as a stand-alone package, please also download +the contents of the externals/ subdirectory. Furthermore this includes git +repos and zip archives like: + +* parse-crontab: Parse and use crontab schedules in Python - Version .14 + (from
https://github.com/josiahcarlson/parse-crontab
) + Checkout the gip repository and copy the 'crontab' dir into the path + 'externals/crontab' afterwards. + +* lunatic-python: Two-way bridge between Python and Lua - Version 1.0 + (from
http://labix.org/lunatic-python
) + Download the zip archive and unpack the 'lunatic-python-1.0' dir into the + path 'externals/_lua' afterwards. + Patch package dir in order to work with newer lua (>= 5.1) versions + $ patch -p1 -d [path-to-install-dir]/_lua < [path-to-externals]/patch-lua + and you are done. + For the sake of completeness, the command invoked to create the patch was: + $ diff -Naur lunatic-python-1.0 _lua > patch-lua Added: branches/rewrite/externals/patch-lua =================================================================== --- branches/rewrite/externals/patch-lua (rev 0) +++ branches/rewrite/externals/patch-lua 2013-04-25 08:29:15 UTC (rev 11449) @@ -0,0 +1,127 @@ +diff -Naur lunatic-python-1.0/__init__.py _lua/__init__.py +--- lunatic-python-1.0/__init__.py 1970-01-01 01:00:00.000000000 +0100 ++++ _lua/__init__.py 2013-04-25 10:10:06.007753009 +0200 +@@ -0,0 +1,38 @@ ++# patches applied for compatibility with lua5.1: ++#
https://github.com/bastibe/lunatic-python/issues/1
++#
http://lua-users.org/wiki/LunaticPython
++ ++import sys, os ++ ++scriptdir = os.path.dirname(sys.argv[0]) ++if not os.path.isabs(scriptdir): ++ scriptdir = os.path.abspath(os.path.join(os.curdir, scriptdir)) ++ ++libdir = os.path.join(scriptdir, '../externals/_lua/build/lib.linux-x86_64-%s.%s' % sys.version_info[:2]) ++if not os.path.exists(libdir): ++ os.makedirs(libdir) ++# path has to exist BEFORE appending, otherwise the re-import fails ++sys.path.append(libdir) ++ ++try: ++ # try to import ++ from lua import * ++except ImportError, e: ++ print "(re-)compilation triggered because of: '%s'" % e ++ ++ cur = os.path.abspath(os.curdir) ++ os.chdir( os.path.join(scriptdir, '../externals/_lua') ) ++ ++ # remove/reset if existing already ++ if os.path.exists(os.path.join(libdir, 'lua.so')): ++ os.remove( os.path.join(libdir, 'lua.so') ) ++ ++ # compile python module (may be use 'distutil' instead of 'make' here) ++ if os.system("python setup.py build"): ++ #if os.system("make"): ++ raise ImportError("'lua.so' could not be compiled!") ++ ++ os.chdir( cur ) ++ ++ # re-try to import ++ from lua import * +diff -Naur lunatic-python-1.0/python.lua _lua/python.lua +--- lunatic-python-1.0/python.lua 2003-12-13 05:37:57.000000000 +0100 ++++ _lua/python.lua 2012-12-28 22:09:07.000000000 +0100 +@@ -1,6 +1,6 @@ + local path = os.getenv("LUA_SOPATH") + if path then +- func = loadlib(path.."/lua-python.so", "luaopen_python") ++ func = package.loadlib(path.."/lua-python.so", "luaopen_python") + if func then + func() + return +@@ -10,7 +10,7 @@ + local loaded = false + for i = 10, 2, -1 do + for j = 10, 2, -1 do +- func = loadlib(string.format(modmask, i, j), "luaopen_python") ++ func = package.loadlib(string.format(modmask, i, j), "luaopen_python") + if func then + loaded = true + func() +diff -Naur lunatic-python-1.0/setup.py _lua/setup.py +--- lunatic-python-1.0/setup.py 2005-10-19 01:10:07.000000000 +0200 ++++ _lua/setup.py 2013-04-25 00:05:34.776479704 +0200 +@@ -1,7 +1,7 @@ + #!/usr/bin/python + from distutils.core import setup, Extension + from distutils.sysconfig import get_python_lib, get_python_version +-import os ++import os, platform + + if os.path.isfile("MANIFEST"): + os.unlink("MANIFEST") +@@ -9,7 +9,13 @@ + # You may have to change these + PYLIBS = ["python"+get_python_version(), "pthread", "util"] + PYLIBDIR = [get_python_lib(standard_lib=True)+"/config"] +-LUALIBS = ["lua", "lualib"] ++pltfrm = platform.platform().lower() ++if 'ubuntu' in pltfrm: ++ LUALIBS = ["lua5.1"] ++elif 'fedora' in pltfrm: ++ LUALIBS = ["lua"] ++else: ++ LUALIBS = ["lua5.1"] + LUALIBDIR = [] + + setup(name="lunatic-python", +@@ -31,13 +37,13 @@ + ["src/pythoninlua.c", "src/luainpython.c"], + library_dirs=PYLIBDIR, + libraries=PYLIBS, +- extra_compile_args=["-rdynamic"], ++ extra_compile_args=["-rdynamic", "-I/usr/include/lua5.1"], + extra_link_args=["-rdynamic"]), + Extension("lua", + ["src/pythoninlua.c", "src/luainpython.c"], + library_dirs=LUALIBDIR, + libraries=LUALIBS, +- extra_compile_args=["-rdynamic"], ++ extra_compile_args=["-rdynamic", "-I/usr/include/lua5.1"], + extra_link_args=["-rdynamic"]), + ], + ) +diff -Naur lunatic-python-1.0/src/luainpython.c _lua/src/luainpython.c +--- lunatic-python-1.0/src/luainpython.c 2005-10-19 01:07:02.000000000 +0200 ++++ _lua/src/luainpython.c 2012-12-28 22:09:07.000000000 +0100 +@@ -488,12 +488,12 @@ + + if (!L) { + L = lua_open(); +- luaopen_base(L); +- luaopen_table(L); +- luaopen_io(L); +- luaopen_string(L); +- luaopen_debug(L); +- luaopen_loadlib(L); ++ ++ /* loading each lib separately has some deep conflict ++ * with python's readline module so we obey the holy ++ * docs by lua people and use the magic loader. ++ */ ++ luaL_openlibs(L); + luaopen_python(L); + lua_settop(L, 0); + } Modified: branches/rewrite/scripts/script_wui.py =================================================================== --- branches/rewrite/scripts/script_wui.py 2013-04-24 17:30:40 UTC (rev 11448) +++ branches/rewrite/scripts/script_wui.py 2013-04-25 08:29:15 UTC (rev 11449) @@ -57,8 +57,8 @@ # --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- # __version__ = '$Id$' -__framework_rev__ = '11445' # check:
http://de.wikipedia.org/wiki/Hilfe:MediaWiki/Versionen
-__release_ver__ = '1.5.%i' # increase minor (1.x) at re-merges with framework +__framework_rev__ = '11448' # check:
http://de.wikipedia.org/wiki/Hilfe:MediaWiki/Versionen
+__release_ver__ = '1.5.%s' # increase minor (1.x) at re-merges with framework # @@ -69,10 +69,11 @@ #
http://labix.org/lunatic-python
try: - import lua # install f15 packages: 'lua', 'lunatic-python' + import lua # installed packages (on f15: 'lua', 'lunatic-python') except ImportError: - import dtbext._lua as lua # TS/labs (debian/ubuntu) -import dtbext.crontab + import _lua as lua # compiled in externals with patch (ubuntu on TS/labs) +#
https://github.com/josiahcarlson/parse-crontab
+import crontab import pywikibot import pywikibot.botirc @@ -167,15 +168,15 @@ def do_check_CronJobs(self): # check cron/date (changes of self.refs are tracked (and reload) in on_pubmsg) - page = self.refs[self.templ] - crontab = self.refs[self.cron].get() + page = self.refs[self.templ] + ctab = self.refs[self.cron].get() # extract 'rev' and 'timestmp' from 'crontab' page text ... - for line in crontab.splitlines(): # hacky/ugly/cheap; already better done in trunk dtbext + for line in ctab.splitlines(): # hacky/ugly/cheap; already better done in trunk dtbext (rev, timestmp) = [item.strip() for item in line[1:].split(',')] # [min] [hour] [day of month] [month] [day of week] # (date supported only, thus [min] and [hour] dropped) - entry = dtbext.crontab.CronTab(timestmp) + entry = crontab.CronTab(timestmp) # find the delay from current minute (does not return 0.0 - but next) delay = entry.next(datetime.datetime.now().replace(second=0,microsecond=0)-datetime.timedelta(microseconds=1)) #pywikibot.output(u'CRON delay for execution: %.3f (<= %i)' % (delay, bot_config['CRONMaxDelay']))
1
0
0
0
SVN: [11448] trunk/pywikipedia/wikipedia.py
by drtrigon@svn.wikimedia.org
24 Apr '13
24 Apr '13
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11448
Revision: 11448 Author: drtrigon Date: 2013-04-24 17:30:40 +0000 (Wed, 24 Apr 2013) Log Message: ----------- bug fix; follow-up to r11447 from rewrite Modified Paths: -------------- trunk/pywikipedia/wikipedia.py Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2013-04-24 17:00:58 UTC (rev 11447) +++ trunk/pywikipedia/wikipedia.py 2013-04-24 17:30:40 UTC (rev 11448) @@ -9188,7 +9188,7 @@ # imported modules output(u'MODULES:') for item in sys.modules.keys(): - ver = version.getfileversion('%s.py' % item) + ver = version.getfileversion('%s.py' % item.replace('.', '/')) if ver and (ver[0] == u'$'): output(u' %s' % ver)
1
0
0
0
SVN: [11447] trunk/pywikipedia/pywikibot/version.py
by drtrigon@svn.wikimedia.org
24 Apr '13
24 Apr '13
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11447
Revision: 11447 Author: drtrigon Date: 2013-04-24 17:00:58 +0000 (Wed, 24 Apr 2013) Log Message: ----------- improvement; version handling and verbose output from rewrite Modified Paths: -------------- trunk/pywikipedia/pywikibot/version.py Modified: trunk/pywikipedia/pywikibot/version.py =================================================================== --- trunk/pywikipedia/pywikibot/version.py 2013-04-24 16:55:33 UTC (rev 11446) +++ trunk/pywikipedia/pywikibot/version.py 2013-04-24 17:00:58 UTC (rev 11447) @@ -54,9 +54,8 @@ version = wikipedia.__version__ id, file, rev, date, ts, author, dollar = version.split(' ') - tag = '' + tag = 'wikipedia.py' date = time.strptime('%sT%s' % (date, ts), '%Y-%m-%dT%H:%M:%SZ') - rev += ' (wikipedia.py)' except: # nothing worked; version unknown (but suppress exceptions) # the value is most likely '$Id' + '$', it means that # wikipedia.py got imported without using svn at all
1
0
0
0
← Newer
1
2
3
4
5
6
7
...
18
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Results per page:
10
25
50
100
200