1
2 '''
3 # DESCRIPTION:
4 # Entropy Object Oriented Interface
5
6 Copyright (C) 2007-2009 Fabio Erculiani
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 '''
22 from entropy.qa import ErrorReportInterface
23 from entropy.client.interfaces import Client
24 from entropy.core import SystemSettings
25 from entropy.const import etpConst
26 from entropy.exceptions import IncorrectParameter, OnlineMirrorError, \
27 PermissionDenied
28 from entropy.i18n import _
29
31
32 """
33 Entropy Errors Reporting Interface that works over User Generated
34 Content (UGC) infrastructure. This version is bound to a specific
35 repository which MUST provide UGC services, otherwise, the error
36 submission will fail.
37
38 This class will allow Entropy repository maintainers to know about
39 critical errors happened during normal operation.
40 Here is an example on how to use this:
41
42 error_interface = UGCErrorReportInterface('sabayonlinux.org')
43 error_interface.prepare()
44 reported = error_interface.submit()
45 if reported:
46 print("error reported succesfully")
47 else:
48 print("cannot report error")
49 """
50
51 - def __init__(self, repository_id = None):
76
78 """
79 Overloaded method from ErrorReportInterface.
80 Does the actual error submission. You must call it after prepare().
81
82 @return submission status -- bool
83 """
84
85 def convert_to_str(el):
86 if not isinstance(el, basestring):
87 el = str(el)
88 return el
89
90 if self.generated:
91 done, err_msg = self.entropy.UGC.report_error(self.__repository_id,
92 self.params)
93 if done:
94 return True
95 return False
96 else:
97 mytxt = _("Not prepared yet")
98 raise PermissionDenied("PermissionDenied: %s" % (mytxt,))
99