[Pywikipedia-l] SVN: [4861] trunk/pywikipedia/commonsdelinker/image_replacer.py

btongminh at svn.wikimedia.org btongminh at svn.wikimedia.org
Sat Jan 12 20:48:36 UTC 2008


Revision: 4861
Author:   btongminh
Date:     2008-01-12 20:48:35 +0000 (Sat, 12 Jan 2008)

Log Message:
-----------
Better error handling

Modified Paths:
--------------
    trunk/pywikipedia/commonsdelinker/image_replacer.py

Modified: trunk/pywikipedia/commonsdelinker/image_replacer.py
===================================================================
--- trunk/pywikipedia/commonsdelinker/image_replacer.py	2008-01-12 17:43:36 UTC (rev 4860)
+++ trunk/pywikipedia/commonsdelinker/image_replacer.py	2008-01-12 20:48:35 UTC (rev 4861)
@@ -212,9 +212,10 @@
 		try:
 			self.report(args)
 		except Exception, e:
-			output(u'A critical error during reporting has occured!')
+			output(u'A critical error during reporting has occured!', False)
 			output('%s: %s' % (e.__class__.__name__, str(e)), False)
 			traceback.print_exc(file = sys.stderr)
+			sys.stderr.flush()
 			self.exit()
 			os.kill(0, signal.SIGTERM)
 			
@@ -272,10 +273,11 @@
 			R = Replacer()
 			output(u'This bot runs from: ' + str(R.site))
 			R.start()
+		except (SystemExit, KeyboardInterrupt):
+			raise
 		except Exception, e:
-			if type(e) not in (SystemExit, KeyboardInterrupt):
-				output('A critical error has occured! Aborting!')
-				traceback.print_exc(file = sys.stderr)
+			output('A critical error has occured! Aborting!')
+			traceback.print_exc(file = sys.stderr)
 	finally:
 		R.reporters.exit()
 		wikipedia.stopme()





More information about the Pywikipedia-l mailing list