weblogsping.py error handling patch
Ryan Barrett <pyblosxom-6sb6M7qyT/[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.devel |
|---|---|
| Message-ID | <[email protected]> |
hi wari, pyblosxom-devel. i've attached a small patch for weblogsping.py, against the version in the 1.3 contrib pack. right now, if it can't connect to weblogs.com or ping.blo.gs, or gets a 5xx HTTP response code, or hits an XML-RPC fault, it lets the exception propagate up to pyblosxom. pyblosxom then dies and shows the user an ugly error message. this patch handles the exception, logs an error, and lets pyblosxom continue rendering the page. -Ryan p.s. i'll start submitting patches against svn, instead of 1.3, Real Soon Now. promise! :P -- http://snarfed.org/ ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Pyblosxom-devel mailing list Pyblosxom-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/pyblosxom-devel
weblogsping_error_handling.patch
(text/plain, 2.6 KB)
*** /usr/home/ryanb/archive/contrib.1.3.0/plugins/weblogsping.py Tue May 30 20:01:35 2006 --- /usr/home/ryanb/archive/contrib_patched/plugins/weblogsping.py Tue Aug 29 15:08:42 2006 *************** *** 42,49 **** __author__ = "Wari Wahab [email protected]" __version__ = "$Id: weblogsping.py 883 2006-03-24 03:43:42Z willhelm $" ! import xmlrpclib, os, time import cPickle as pickle class WeblogsPing: def __init__(self, request): --- 42,50 ---- __author__ = "Wari Wahab [email protected]" __version__ = "$Id: weblogsping.py 883 2006-03-24 03:43:42Z willhelm $" ! import xmlrpclib, os, sys, time import cPickle as pickle + from Pyblosxom import tools class WeblogsPing: def __init__(self, request): *************** *** 89,102 **** # Save this data first else we'll go crazy with looping if not self.__saveResults(pingTime, 'buffer', 'buffer'): return # Ping both servers now. ! rpc = xmlrpclib.Server('http://ping.blo.gs/') ! response = rpc.weblogUpdates.extendedPing(self._title, ! self._site, self._xml, self._xml) ! rpc = xmlrpclib.Server('http://rpc.weblogs.com/RPC2') ! response1 = rpc.weblogUpdates.ping(self._title, self._site) ! # save result of ping in self._file, note, no output is done ! self.__saveResults(pingTime, response, response1) def __saveResults(self, pingTime, response, response1): latest = (pingTime == 0 and 1 or self._latest) --- 90,111 ---- # Save this data first else we'll go crazy with looping if not self.__saveResults(pingTime, 'buffer', 'buffer'): return + # Ping both servers now. ! logger = tools.getLogger() ! try: ! rpc = xmlrpclib.Server('http://ping.blo.gs/') ! response = rpc.weblogUpdates.extendedPing( ! self._title, self._site, self._xml, self._xml) ! rpc = xmlrpclib.Server('http://rpc.weblogs.com/RPC2') ! response1 = rpc.weblogUpdates.ping(self._title, self._site) ! ! # save result of ping in self._file, note, no output is done ! self.__saveResults(pingTime, response, response1) ! except: ! logger.error("Error during ping: %s, %s" % (str(sys.exc_type), ! str(sys.exc_value))) ! def __saveResults(self, pingTime, response, response1): latest = (pingTime == 0 and 1 or self._latest)