| Home | Trees | Indices | Help |
|
|---|
|
|
1 # -*- coding: utf-8 -*-
2 """
3
4 @author: Fabio Erculiani <lxnay@sabayonlinux.org>
5 @contact: lxnay@sabayonlinux.org
6 @copyright: Fabio Erculiani
7 @license: GPL-2
8
9 B{Entropy Package Manager Client QA Interface}.
10
11 """
12 from entropy.qa import ErrorReportInterface
13 from entropy.client.interfaces import Client
14 from entropy.core.settings.base import SystemSettings
15 from entropy.const import etpConst
16 from entropy.exceptions import IncorrectParameter, OnlineMirrorError, \
17 PermissionDenied
18 from entropy.i18n import _
19
21
22 """
23 Entropy Errors Reporting Interface that works over User Generated
24 Content (UGC) infrastructure. This version is bound to a specific
25 repository which MUST provide UGC services, otherwise, the error
26 submission will fail.
27
28 This class will allow Entropy repository maintainers to know about
29 critical errors happened during normal operation.
30 Here is an example on how to use this:
31
32 error_interface = UGCErrorReportInterface('sabayonlinux.org')
33 error_interface.prepare()
34 reported = error_interface.submit()
35 if reported:
36 print("error reported succesfully")
37 else:
38 print("cannot report error")
39 """
40
42 """
43 object constructor, repository_id must be a valid repository
44 identifier.
45
46 @param repository_id -- valid repository identifier
47 @type basestring
48 """
49 ErrorReportInterface.__init__(self, '#fake#')
50 self.__system_settings = SystemSettings()
51
52 if repository_id == None:
53 repository_id = etpConst['officialserverrepositoryid']
54
55 self.entropy = Client()
56 self.__repository_id = repository_id
57 if self.entropy.UGC == None:
58 # enable UGC
59 from entropy.client.services.ugc.interfaces import Client as ugc
60 self.entropy.UGC = ugc(self.entropy)
61
62 if repository_id not in self.__system_settings['repositories']['order']:
63 raise IncorrectParameter('invalid repository_id provided')
64 if not self.entropy.UGC.is_repository_eapi3_aware(repository_id):
65 raise OnlineMirrorError('UGC not supported by the provided repo')
66
68 """
69 Overloaded method from ErrorReportInterface.
70 Does the actual error submission. You must call it after prepare().
71
72 @return submission status -- bool
73 """
74
75 if self.generated:
76 done, err_msg = self.entropy.UGC.report_error(self.__repository_id,
77 self.params)
78 if done:
79 return True
80 return False
81 else:
82 mytxt = _("Not prepared yet")
83 raise PermissionDenied("PermissionDenied: %s" % (mytxt,))
84
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Fri Sep 4 11:50:17 2009 | http://epydoc.sourceforge.net |