[entropy.spm] make SPM backend user configurable

This commit is contained in:
Fabio Erculiani
2009-08-19 13:11:15 +02:00
parent c77c004cbe
commit 82d3e01bd4
3 changed files with 37 additions and 5 deletions

View File

@@ -77,3 +77,18 @@ system-name|Sabayon Linux
#
# Entropy processes nice level
# nice-level|0
#
# syntax for spm-backend:
#
# spm-backend: Change Entropy Source Package Manager backend interface.
# Currently supported is "portage". Pay attention to edit this
# parameter, it could cause your Entropy to fail loading!
#
# spm-backend|[supported backend identifier]
#
# example:
# spm-backend|portage
#
# Default SPM backend value:
# spm-backend|portage

View File

@@ -1016,10 +1016,12 @@ class SystemSettings(Singleton):
@rtype: dict
"""
data = {}
data['proxy'] = etpConst['proxy'].copy()
data['name'] = etpConst['systemname']
data['log_level'] = etpConst['entropyloglevel']
data = {
'proxy': etpConst['proxy'].copy(),
'name': etpConst['systemname'],
'log_level': etpConst['entropyloglevel'],
'spm_backend': etpConst['spm']['backend'],
}
etp_conf = self.__setting_files['system']
if not os.path.isfile(etp_conf) and \
@@ -1081,6 +1083,11 @@ class SystemSettings(Singleton):
data['name'] = split_line[1].strip()
elif line.startswith("spm-backend|") and \
(split_line_len == 2):
data['spm_backend'] = split_line[1].strip()
elif line.startswith("nice-level|") and \
(split_line_len == 2):

View File

@@ -12,6 +12,8 @@
import os
import sys
from entropy.const import etpConst
from entropy.core import SystemSettings
from entropy.i18n import _
from entropy.spm.plugins.skel import SpmPlugin
PLUGIN_SUFFIX = "_plugin"
_AVAILABLE_CACHE = None
@@ -70,10 +72,18 @@ def get_default_class():
"""
Return currently configured Entropy Source Package Manager plugin class.
"""
backend = etpConst['spm']['backend']
settings = SystemSettings()
backend = settings['system'].get('spm_backend', etpConst['spm']['backend'])
available = get_available_plugins()
klass = available.get(backend)
if klass is None:
import warnings
warnings.warn("%s: %s" % (
_("selected SPM backend not available"), backend,))
klass = available.get(etpConst['spm']['backend'])
return available[backend]
def get_default_instance(output_interface):
"""
Return the currently configured Entropy SPM interface instance.