Package entropy :: Package client :: Package interfaces :: Module qa

Source Code for Module entropy.client.interfaces.qa

  1  # -*- coding: utf-8 -*- 
  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   
30 -class UGCErrorReportInterface(ErrorReportInterface):
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):
52 """ 53 object constructor, repository_id must be a valid repository 54 identifier. 55 56 @param repository_id -- valid repository identifier 57 @type basestring 58 """ 59 ErrorReportInterface.__init__(self) 60 self.__system_settings = SystemSettings() 61 62 if repository_id == None: 63 repository_id = etpConst['officialserverrepositoryid'] 64 65 self.entropy = Client() 66 self.__repository_id = repository_id 67 if self.entropy.UGC == None: 68 # enable UGC 69 from entropy.client.services.ugc.interfaces import Client as ugc 70 self.entropy.UGC = ugc(self.entropy) 71 72 if repository_id not in self.__system_settings['repositories']['order']: 73 raise IncorrectParameter('invalid repository_id provided') 74 if not self.entropy.UGC.is_repository_eapi3_aware(repository_id): 75 raise OnlineMirrorError('UGC not supported by the provided repo')
76
77 - def submit(self):
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