1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import gettext
24 t = gettext.translation('rhn-client-tools', fallback=True)
25
26 if not hasattr(t, 'ugettext'):
27 t.ugettext = t.gettext
28 _ = t.ugettext
29 import OpenSSL
30 from platform import dist
31 from rhn.i18n import ustr
32 from up2date_client import config
33 from up2date_client import up2dateLog
34 from up2date_client.pkgplatform import getPlatform
35
36 import sys
37 sys.path = sys.path[1:] + sys.path[:1]
38
39 try:
40 from yum.Errors import YumBaseError as PmBaseError
41 except ImportError:
42 try:
43 from dnf.exceptions import Error as PmBaseError
44 except ImportError:
49 raise AttributeError(_("class %s has no attribute '%s'") % (self.__class__.__name__, name))
51 if name in ['errmsg', 'value']:
52 self.__dict__['value'] = value
53 else:
54 self.__dict__[name] = value
55
56
58 """base class for errors"""
59 premsg = ''
65
67 self.log.log_me(self.value)
68 return self.value
69
71 """ Spacewalk backend still use errmsg, let have errmsg as alias to value """
72 if name == 'errmsg':
73 return self.value
74 else:
75 if hasattr(PmBaseError, '__getattr__'):
76
77 return PmBaseError.__getattr__(self, name)
78 else:
79 if name in self.__dict__:
80 return self.__dict__[name]
81 else:
82 raise AttributeError(_("class %s has no attribute '%s'") % (self.__class__.__name__, name))
83
85 """ Spacewalk backend still use errmsg, let have errmsg as alias to value """
86 if name == 'errmsg':
87 self.__dict__['value'] = value
88 else:
89 if hasattr(PmBaseError, '__setattr__'):
90
91 PmBaseError.__setattr__(self, name, value)
92 else:
93 self.__dict__[name] = value
94
97
98 try:
99 from yum.Errors import RepoError
100 except ImportError:
101 try:
102 from dnf.exceptions import RepoError
103 except ImportError:
104 RepoError = DebAndSuseRepoError
105
106
108 """rpm itself raised an error condition"""
109 premsg = _("RPM error. The message was:\n")
110
113
115 """Raise when the server responds with that a password is incorrect"""
116 premsg = _("Password error. The message was:\n")
117
119 """Raise when a rpm transaction set has a dependency error"""
120 premsg = _("RPM dependency error. The message was:\n")
126
127
129 """Indicates a problem doing xml-rpc http communication with the server"""
130 premsg = _("Error communicating with server. "\
131 "The message was:\n")
132
134 """
135 Raise when a package or header that is requested returns
136 a 404 error code"""
137 premsg = _("File Not Found: \n")
138
139
141 """
142 Raise when the expected response from a xml-rpc call
143 exceeds a timeout"""
144 premsg = _("Delay error from server. The message was:\n")
145
147 """
148 Raise when we can't remove a package for some reason
149 (failed deps, etc)"""
151 Error.__init__(self, "")
152 self.args = args
153 for key in self.args.keys():
154 self.args[key] = ustr(self.args[key])
155 self.value = self.value + "%s failed because of %s\n" % (
156 key, self.args[key])
157 self.data = self.args
160
163 msg = ustr(msg)
164 self.value = self.premsg + msg
165
168
171
174
177
179 """indicates an error during server input validation"""
180 premsg = _("Error validating data at server:\n")
181
184
188
191
193 return _("""
194 Red Hat Network Classic is not supported.
195 To register with Red Hat Subscription Management please run:
196
197 subscription-manager register --auto-attach
198
199 Get more information at access.redhat.com/knowledge
200 """)
201
203 """indicates an error during server input validation"""
204 premsg = _("The installation number is invalid")
205
207 premsg = _("Error parsing the oemInfo file at field:\n")
208
210 """No valid base channel was found for this system"""
211 pass
212
215
218
220 - def __init__(self, msg, errorlist=None):
221 Error.__init__(self, msg)
222 self.errorlist = []
223 if errorlist:
224 self.errorlist=errorlist
225
228
231
233 """ some generic network error occurred, e.g. connection reset by peer """
234 premsg = _("Network error: ")
235
238
239
240 up2dateConfig = config.initUp2dateConfig()
241 certFile = up2dateConfig['sslCACert']
242 f = open(certFile, "r")
243 buf = f.read()
244 f.close()
245 tempCert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, buf)
246 if tempCert.has_expired():
247 RepoError.__init__(self ,"The certificate %s is expired. Please ensure you have the correct"
248 " certificate and your system time is correct." % certFile)
249 else:
250 RepoError.__init__(self, "The SSL certificate failed verification.")
251
252 __getattr__ = Error.__getattr__
253
256
257
259 """Class that can represent different things depending on context:
260 While logging in with an existing user it represents a username or password
261 being incorrect.
262 While creating a new account, it represents the username already being
263 taken or the user not being allowed to create an account.
264 Optimally these different things would be different exceptions, but there
265 are single fault codes the server can return to the client that can mean
266 more than one of them so we have no way of knowing which is actually
267 intended.
268
269 """
270 pass
271
274
277
280
283
286
289
292
293
297
300
302 newExpln = _("""
303 Your organization does not have enough Management entitlements to register this
304 system to Red Hat Satellite. Please notify your organization administrator of this error.
305 You should be able to register this system after your organization frees existing
306 or purchases additional entitlements. Additional entitlements may be purchased by your
307 organization administrator by logging into Red Hat Network Classic and visiting
308 the 'Subscription Management' page in the 'Your RHN' section of RHN.
309
310 A common cause of this error code is due to having mistakenly setup an
311 Activation Key which is set as the universal default. If an activation key is set
312 on the account as a universal default, you can disable this key and retry to avoid
313 requiring a Management entitlement.""")
314 term = "Explanation:"
315 loc = msg.rindex(term) + len(term)
316 return msg[:loc] + newExpln
317
320
322 """ Raise when redirect requests could'nt return a package"""
323 pass
324