[Pywikipedia-l] SVN: [5706] trunk/pywikipedia
nicdumz at svn.wikimedia.org
nicdumz at svn.wikimedia.org
Thu Jul 10 05:46:47 UTC 2008
Revision: 5706
Author: nicdumz
Date: 2008-07-10 05:46:47 +0000 (Thu, 10 Jul 2008)
Log Message:
-----------
* Removing multiple stopme() calls, to use a single stopme() exit point per file, when possible
* Passing when OSError is raised in stopme
Modified Paths:
--------------
trunk/pywikipedia/blockpageschecker.py
trunk/pywikipedia/capitalize_redirects.py
trunk/pywikipedia/casechecker.py
trunk/pywikipedia/checkimages.py
trunk/pywikipedia/clean_sandbox.py
trunk/pywikipedia/copyright.py
trunk/pywikipedia/get.py
trunk/pywikipedia/lonelypages.py
trunk/pywikipedia/pagefromfile.py
trunk/pywikipedia/reflinks.py
trunk/pywikipedia/replace.py
trunk/pywikipedia/standardize_notes.py
trunk/pywikipedia/watchlist.py
trunk/pywikipedia/wikicomserver.py
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/blockpageschecker.py
===================================================================
--- trunk/pywikipedia/blockpageschecker.py 2008-07-10 05:43:04 UTC (rev 5705)
+++ trunk/pywikipedia/blockpageschecker.py 2008-07-10 05:46:47 UTC (rev 5706)
@@ -195,7 +195,7 @@
global categoryToCheck; global comment; global project_inserted
if config.mylang not in project_inserted:
wikipedia.output(u"Your project is not supported by this script. You have to edit the script and add it!")
- wikipedia.stopme()
+ return
# always, define a generator to understand if the user sets one, defining what's genFactory
always = False; generator = False; debug = False
moveBlockCheck = False; genFactory = pagegenerators.GeneratorFactory()
Modified: trunk/pywikipedia/capitalize_redirects.py
===================================================================
--- trunk/pywikipedia/capitalize_redirects.py 2008-07-10 05:43:04 UTC (rev 5705)
+++ trunk/pywikipedia/capitalize_redirects.py 2008-07-10 05:46:47 UTC (rev 5706)
@@ -162,9 +162,8 @@
referredPage = wikipedia.Page(wikipedia.getSite(), referredPageName)
gen = pagegenerators.ReferringPageGenerator(referredPage)
elif source == None or len(commandline_replacements) not in [0, 2]:
- wikipedia.stopme()
wikipedia.showHelp(u'capitalize_redirects')
- sys.exit()
+ return
if namespaces != []:
gen = pagegenerators.NamespaceFilterPageGenerator(gen, namespaces)
preloadingGen = pagegenerators.PreloadingGenerator(gen, pageNumber = 20)
Modified: trunk/pywikipedia/casechecker.py
===================================================================
--- trunk/pywikipedia/casechecker.py 2008-07-10 05:43:04 UTC (rev 5705)
+++ trunk/pywikipedia/casechecker.py 2008-07-10 05:46:47 UTC (rev 5706)
@@ -352,7 +352,6 @@
except:
if self.apfrom is not None:
wikipedia.output(u'Exception at Title = %s, Next = %s' % (title, self.apfrom))
- wikipedia.stopme()
raise
def WikiLog(self, text):
Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py 2008-07-10 05:43:04 UTC (rev 5705)
+++ trunk/pywikipedia/checkimages.py 2008-07-10 05:46:47 UTC (rev 5706)
@@ -1065,7 +1065,7 @@
# A little block-statement to ensure that the bot will not start with en-parameters
if site.lang not in project_inserted:
wikipedia.output(u"Your project is not supported by this script. You have to edit the script and add it!")
- wikipedia.stopme()
+ return
# Some formatting for delete immediately template
di = '\n%s' % di
dels = dels % di
@@ -1403,10 +1403,6 @@
# Here there is the main loop. I'll take all the (name of the) images and then i'll check them.
if __name__ == "__main__":
try:
- #try:
checkbot()
- #except wikipedia.BadTitle:
- # wikipedia.output(u"Wikidown or server's problem, quit")
- # wikipedia.stopme()
finally:
wikipedia.stopme()
Modified: trunk/pywikipedia/clean_sandbox.py
===================================================================
--- trunk/pywikipedia/clean_sandbox.py 2008-07-10 05:43:04 UTC (rev 5705)
+++ trunk/pywikipedia/clean_sandbox.py 2008-07-10 05:46:47 UTC (rev 5706)
@@ -119,7 +119,6 @@
wikipedia.output(u'*** Loading again because of edit conflict.\n')
if self.no_repeat:
wikipedia.output(u'\nDone.')
- wikipedia.stopme()
return
else:
wikipedia.output(u'\nSleeping %s hours, now %s' % (self.hours, now))
@@ -134,7 +133,6 @@
no_repeat = False
else:
wikipedia.showHelp('clean_sandbox')
- wikipedia.stopme()
return
bot = SandboxBot(hours, no_repeat)
Modified: trunk/pywikipedia/copyright.py
===================================================================
--- trunk/pywikipedia/copyright.py 2008-07-10 05:43:04 UTC (rev 5705)
+++ trunk/pywikipedia/copyright.py 2008-07-10 05:46:47 UTC (rev 5706)
@@ -1170,8 +1170,7 @@
wikipedia.output(output)
if not gen:
- wikipedia.stopme()
- sys.exit()
+ return
if namespaces != []:
gen = pagegenerators.NamespaceFilterPageGenerator(gen, namespaces)
preloadingGen = pagegenerators.PreloadingGenerator(gen, pageNumber = pageNumber)
Modified: trunk/pywikipedia/get.py
===================================================================
--- trunk/pywikipedia/get.py 2008-07-10 05:43:04 UTC (rev 5705)
+++ trunk/pywikipedia/get.py 2008-07-10 05:46:47 UTC (rev 5706)
@@ -31,9 +31,6 @@
if __name__ == "__main__":
try:
main()
- except:
+ finally:
wikipedia.stopme()
- raise
- else:
- wikipedia.stopme()
Modified: trunk/pywikipedia/lonelypages.py
===================================================================
--- trunk/pywikipedia/lonelypages.py 2008-07-10 05:43:04 UTC (rev 5705)
+++ trunk/pywikipedia/lonelypages.py 2008-07-10 05:46:47 UTC (rev 5706)
@@ -170,7 +170,7 @@
# (useful when the bot is run on a server)
if getenable != 'enable':
wikipedia.output('The bot is disabled')
- wikipedia.stopme()
+ return
# DisambigPage part
if disambigPage != None:
disambigpage = wikipedia.Page(wikiSite, disambigPage)
Modified: trunk/pywikipedia/pagefromfile.py
===================================================================
--- trunk/pywikipedia/pagefromfile.py 2008-07-10 05:43:04 UTC (rev 5705)
+++ trunk/pywikipedia/pagefromfile.py 2008-07-10 05:46:47 UTC (rev 5706)
@@ -322,8 +322,5 @@
if __name__ == "__main__":
try:
main()
- except:
+ finally:
wikipedia.stopme()
- raise
- else:
- wikipedia.stopme()
Modified: trunk/pywikipedia/reflinks.py
===================================================================
--- trunk/pywikipedia/reflinks.py 2008-07-10 05:43:04 UTC (rev 5705)
+++ trunk/pywikipedia/reflinks.py 2008-07-10 05:46:47 UTC (rev 5706)
@@ -307,8 +307,7 @@
except wikipedia.NoPage :
wikipedia.output(u'The stop page %s does not exist'
% self.stopPage.aslink())
- wikipedia.stopme()
- sys.exit(1)
+ raise
# Regex to grasp content-type meta HTML tag in HTML source
self.META_CONTENT = re.compile(ur'(?i)<meta[^>]*content\-type[^>]*>')
@@ -671,8 +670,7 @@
if not generator:
# syntax error, show help text from the top of this file
wikipedia.showHelp('reflinks')
- wikipedia.stopme()
- sys.exit()
+ return
generator = pagegenerators.PreloadingGenerator(generator, pageNumber = 50)
generator = pagegenerators.RedirectFilterPageGenerator(generator)
bot = ReferencesRobot(generator, always, limit, ignorepdf)
Modified: trunk/pywikipedia/replace.py
===================================================================
--- trunk/pywikipedia/replace.py 2008-07-10 05:43:04 UTC (rev 5705)
+++ trunk/pywikipedia/replace.py 2008-07-10 05:46:47 UTC (rev 5706)
@@ -606,8 +606,7 @@
except KeyError:
wikipedia.output(u'Available predefined fixes are: %s'
% fixes.fixes.keys())
- wikipedia.stopme()
- sys.exit()
+ return
if fix.has_key('regex'):
regex = fix['regex']
if fix.has_key('msg'):
@@ -675,8 +674,7 @@
if not gen:
# syntax error, show help text from the top of this file
wikipedia.showHelp('replace')
- wikipedia.stopme()
- sys.exit()
+ return
if namespaces != []:
gen = pagegenerators.NamespaceFilterPageGenerator(gen, namespaces)
if xmlFilename:
Modified: trunk/pywikipedia/standardize_notes.py
===================================================================
--- trunk/pywikipedia/standardize_notes.py 2008-07-10 05:43:04 UTC (rev 5705)
+++ trunk/pywikipedia/standardize_notes.py 2008-07-10 05:46:47 UTC (rev 5706)
@@ -1078,8 +1078,7 @@
if source == None or len(commandline_replacements) not in [0, 2]:
# syntax error, show help text from the top of this file
wikipedia.output(__doc__, 'utf-8')
- wikipedia.stopme()
- sys.exit()
+ return
if (len(commandline_replacements) == 2):
replacements[commandline_replacements[0]] = commandline_replacements[1]
wikipedia.setAction(wikipedia.translate(wikipedia.getSite(), msg ) % ' (-' + commandline_replacements[0] + ' +' + commandline_replacements[1] + ')')
@@ -1097,8 +1096,7 @@
fix = fixes['ALTREFS']
except KeyError:
wikipedia.output(u'Available predefined fixes are: %s' % fixes.keys())
- wikipedia.stopme()
- sys.exit()
+ return
if fix.has_key('regex'):
regex = fix['regex']
if fix.has_key('msg'):
Modified: trunk/pywikipedia/watchlist.py
===================================================================
--- trunk/pywikipedia/watchlist.py 2008-07-10 05:43:04 UTC (rev 5705)
+++ trunk/pywikipedia/watchlist.py 2008-07-10 05:46:47 UTC (rev 5706)
@@ -109,9 +109,6 @@
if __name__ == "__main__":
try:
main()
- except:
+ finally:
wikipedia.stopme()
- raise
- else:
- wikipedia.stopme()
Modified: trunk/pywikipedia/wikicomserver.py
===================================================================
--- trunk/pywikipedia/wikicomserver.py 2008-07-10 05:43:04 UTC (rev 5705)
+++ trunk/pywikipedia/wikicomserver.py 2008-07-10 05:46:47 UTC (rev 5706)
@@ -78,7 +78,6 @@
return wrap(page)
def __del__(self):
- wikipedia.stopme()
os.chdir(currDir)
print "ChDir to original ", currDir
@@ -97,5 +96,7 @@
if __name__=='__main__':
import win32com.server.register
- win32com.server.register.UseCommandLine(Wiki)
- wikipedia.stopme()
+ try:
+ win32com.server.register.UseCommandLine(Wiki)
+ finally:
+ wikipedia.stopme()
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-07-10 05:43:04 UTC (rev 5705)
+++ trunk/pywikipedia/wikipedia.py 2008-07-10 05:46:47 UTC (rev 5706)
@@ -6341,7 +6341,11 @@
if config.use_diskcache:
for site in _sites.itervalues():
if site._mediawiki_messages:
- site._mediawiki_messages.delete()
+ try:
+ site._mediawiki_messages.delete()
+ except OSError:
+ # stopme has been called several times...
+ pass
get_throttle.drop()
def _flush():
More information about the Pywikipedia-l
mailing list