diff options
author | Seth Vidal <skvidal@fedoraproject.org> | 2007-09-25 10:27:06 -0400 |
---|---|---|
committer | Seth Vidal <skvidal@fedoraproject.org> | 2007-09-25 10:27:06 -0400 |
commit | fc335d72bd444bc899b07042b7c11c814259f188 (patch) | |
tree | 3ba23a23ae5c1698659a3bcae5c511739035d3b2 /func/CommonErrors.py | |
parent | 7d543b6cf1d721c2e9f7ed88a230172870a9f558 (diff) | |
download | func-fc335d72bd444bc899b07042b7c11c814259f188.tar.gz func-fc335d72bd444bc899b07042b7c11c814259f188.tar.xz func-fc335d72bd444bc899b07042b7c11c814259f188.zip |
- all the class bits to make the authssl xmlrpc server work - most of it copied and modified from plague
- modifications to setup.py to behave with func dir for python sitelib
Diffstat (limited to 'func/CommonErrors.py')
-rw-r--r-- | func/CommonErrors.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/func/CommonErrors.py b/func/CommonErrors.py new file mode 100644 index 0000000..13ef505 --- /dev/null +++ b/func/CommonErrors.py @@ -0,0 +1,62 @@ +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# Copyright 2005 Dan Williams <dcbw@redhat.com> and Red Hat, Inc. + +import socket + + +def canIgnoreSSLError(e): + """ + Identify common network errors that mean we cannot connect to the server + """ + + # This is a bit complicated by the fact that different versions of + # M2Crypto & OpenSSL seem to return different error codes for the + # same type of error + s = "%s" % e + if e[0] == 104: # Connection refused + return True + elif e[0] == 111: # Connection reset by peer + return True + elif e[0] == 61: # Connection refused + return True + elif e[0] == 54: # Connection reset by peer + return True + elif s == "no certificate returned": + return True + elif s == "wrong version number": + return True + elif s == "unexpected eof": + return True + + return False + + +def canIgnoreSocketError(e): + """ + Identify common network errors that mean we cannot connect to the server + """ + + try: + if e[0] == 111: # Connection refused + return True + elif e[0] == 104: # Connection reset by peer + return True + elif e[0] == 61: # Connection refused + return True + except IndexError: + return True + + return False |