diff options
author | Robin Norwood <rnorwood@redhat.com> | 2007-09-25 10:38:51 -0400 |
---|---|---|
committer | Robin Norwood <rnorwood@redhat.com> | 2007-09-25 10:38:51 -0400 |
commit | 6bf3d8bee599802c95832cbdae904ffce1053938 (patch) | |
tree | 6711d28ed442ffbe5fddfdc6ccd1678ec05aa74c /func/CommonErrors.py | |
parent | 5024f7f62ff32345660fae783ac7a97d506fe1da (diff) | |
parent | fca2c8e36dfec0ced3957ba8f6e62bf62a99c84b (diff) | |
download | third_party-func-6bf3d8bee599802c95832cbdae904ffce1053938.tar.gz third_party-func-6bf3d8bee599802c95832cbdae904ffce1053938.tar.xz third_party-func-6bf3d8bee599802c95832cbdae904ffce1053938.zip |
Merge branch 'master' of git+ssh://git.fedoraproject.org/git/hosted/func
Conflicts:
func.spec
setup.py
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 |