[entropy.qa] implement EntropyRepository plugin
This commit is contained in:
+46
-4
@@ -23,13 +23,49 @@ import sys
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
from entropy.const import etpConst, etpSys
|
||||
from entropy.const import etpConst, etpSys, const_debug_write
|
||||
from entropy.output import blue, darkgreen, red, darkred, bold, purple, brown
|
||||
from entropy.exceptions import IncorrectParameter, PermissionDenied, \
|
||||
SystemDatabaseError
|
||||
from entropy.i18n import _
|
||||
from entropy.core.settings.base import SystemSettings
|
||||
|
||||
from entropy.const import const_debug_write
|
||||
from entropy.db import EntropyRepositoryPlugin
|
||||
|
||||
class QAEntropyRepositoryPlugin(EntropyRepositoryPlugin):
|
||||
|
||||
def __init__(self, qa_interface, metadata = None):
|
||||
"""
|
||||
Entropy QA-side repository EntropyRepository Plugin class.
|
||||
This class will be instantiated and automatically added to
|
||||
EntropyRepository instances generated by Entropy QA.
|
||||
|
||||
@param qa_interface: Entropy Client interface instance
|
||||
@type qa_interface: entropy.qa.QAInterface class
|
||||
@param metadata: any dict form metadata map (key => value)
|
||||
@type metadata: dict
|
||||
"""
|
||||
EntropyRepositoryPlugin.__init__(self)
|
||||
self._qa = qa_interface
|
||||
if metadata is None:
|
||||
self._metadata = {}
|
||||
else:
|
||||
self._metadata = metadata
|
||||
|
||||
def add_plugin_hook(self, entropy_repository_instance):
|
||||
const_debug_write(__name__,
|
||||
"QAEntropyRepositoryPlugin: calling add_plugin_hook => %s" % (
|
||||
self,)
|
||||
)
|
||||
|
||||
out_intf = self._metadata.get('output_interface')
|
||||
if out_intf is not None:
|
||||
entropy_repository_instance.updateProgress = out_intf.updateProgress
|
||||
entropy_repository_instance.askQuestion = out_intf.askQuestion
|
||||
|
||||
return 0
|
||||
|
||||
class QAInterfacePlugin:
|
||||
"""
|
||||
Inherit this class to create a QAInterface tests Plugin.
|
||||
@@ -90,10 +126,10 @@ class QAInterface:
|
||||
|
||||
if not hasattr(self.Output, 'updateProgress'):
|
||||
mytxt = _("Output interface has no updateProgress method")
|
||||
raise IncorrectParameter("IncorrectParameter: %s" % (mytxt,))
|
||||
raise AttributeError("AttributeError: %s" % (mytxt,))
|
||||
elif not hasattr(self.Output.updateProgress, '__call__'):
|
||||
mytxt = _("Output interface has no updateProgress method")
|
||||
raise IncorrectParameter("IncorrectParameter: %s" % (mytxt,))
|
||||
raise AttributeError("AttributeError: %s" % (mytxt,))
|
||||
|
||||
def add_plugin(self, plugin):
|
||||
"""
|
||||
@@ -1013,9 +1049,15 @@ class QAInterface:
|
||||
dbname = 'qa_testing',
|
||||
xcache = False,
|
||||
indexing = False,
|
||||
OutputInterface = self.Output,
|
||||
skipChecks = False
|
||||
)
|
||||
etp_repo_meta = {
|
||||
'output_interface': self.Output,
|
||||
}
|
||||
repo_plug = QAEntropyRepositoryPlugin(self,
|
||||
metadata = etp_repo_meta)
|
||||
dbc.add_plugin(repo_plug)
|
||||
|
||||
except dbapi2.Error:
|
||||
os.remove(tmp_path)
|
||||
os.close(fd)
|
||||
|
||||
Reference in New Issue
Block a user