From 7b9c0ccd8633fe2e7bdd9cc45bb937a03526a7ce Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Wed, 3 Dec 2003 04:57:30 +0000 Subject: [PATCH] Changed the name of WebException to WebError. --- plugins/Sourceforge.py | 8 ++++---- src/webutils.py | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/plugins/Sourceforge.py b/plugins/Sourceforge.py index 4e00e5acd..a7309aa8f 100644 --- a/plugins/Sourceforge.py +++ b/plugins/Sourceforge.py @@ -154,7 +154,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable): else: return 'http://sourceforge.net%s%s' % (utils.htmlToText( m.group(1)), self._hrefOpts) - except webutils.WebException, e: + except webutils.WebError, e: raise callbacks.Error, str(e) def _getTrackerList(self, url): @@ -168,7 +168,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable): return '%s' % utils.commaAndify(resp) raise callbacks.Error, 'No Trackers were found. (%s)' %\ conf.replyPossibleBug - except webutils.WebException, e: + except webutils.WebError, e: raise callbacks.Error, e.msg() def _getTrackerInfo(self, irc, msg, url, num): @@ -181,7 +181,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable): return irc.error(msg, 'No Trackers were found. (%s)' % conf.replyPossibleBug) - except webutils.WebException, e: + except webutils.WebError, e: irc.error(msg, e.msg()) _bugLink = re.compile(r'"([^"]+)">Bugs') @@ -317,7 +317,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable): resp.append('%s: %s' % self._bold(m.groups())) irc.reply(msg, '%s #%s: %s' % (ircutils.bold(linktype), ircutils.bold(num), '; '.join(resp)), prefixName = False) - except webutils.WebException, e: + except webutils.WebError, e: self.log.warning(str(e)) sfSnarfer = privmsgs.urlSnarfer(sfSnarfer) diff --git a/src/webutils.py b/src/webutils.py index 628fd79a6..251357ee5 100644 --- a/src/webutils.py +++ b/src/webutils.py @@ -36,22 +36,23 @@ import fix import socket import urllib2 -class WebException(Exception): +class WebError(Exception): pass def getUrlFd(url): + """Gets a file-like object for a url.""" try: fd = urllib2.urlopen(url) return fd except socket.error, e: if e.args[0] == 111: - raise WebException, 'Connection refused.' + raise WebError, 'Connection refused.' elif e.args[0] in (110, 10060): - raise WebException, 'Connection timed out.' + raise WebError, 'Connection timed out.' else: - raise WebException, str(e) + raise WebError, str(e) except (urllib2.HTTPError, urllib2.URLError), e: - raise WebException, str(e) + raise WebError, str(e) def getUrl(url, size=None): """Gets a page. Returns a string that is the page gotten."""