blob: c76cb3d4f5079fe49c36625587aa3e4dc003c156 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# 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.
from exceptions import Exception
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
class Func_Client_Exception(Exception):
def __init__(self, value=None):
Exception.__init__(self)
self.value = value
def __str__(self):
return "%s" %(self.value,)
|