[Kimchi-devel] [PATCH 4/4] Start up Kimchi even if no repo management tool was identified

Adam King rak at linux.vnet.ibm.com
Wed Mar 12 22:14:54 UTC 2014


Reviewed-by: Adam King <rak at linux.vnet.ibm.com>

On 03/11/2014 04:34 PM, Aline Manera wrote:
> From: Aline Manera <alinefm at br.ibm.com>
>
> Kimchi should not block user to use its functionalities if a repository
> management tool was not identified.
> So allow user starts up kimchi and raise an error only if he/she tries
> to use the repository management feature.
>
> Signed-off-by: Aline Manera <alinefm at br.ibm.com>
> ---
>   src/kimchi/i18n.py       |    2 +-
>   src/kimchi/model/host.py |   31 +++++++++++++++++++++++++++++--
>   2 files changed, 30 insertions(+), 3 deletions(-)
>
> diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
> index 1ae3889..ddb2fcb 100644
> --- a/src/kimchi/i18n.py
> +++ b/src/kimchi/i18n.py
> @@ -238,7 +238,7 @@ messages = {
>       "KCHREPOS0011E": _("There is no disabled repository called %(repo_id)s."),
>       "KCHREPOS0012E": _("There is no enabled repository called %(repo_id)s."),
>       "KCHREPOS0013E": _("There are no parameters to update repository."),
> -    "KCHREPOS0014E": _("OS distro not supported."),
> +    "KCHREPOS0014E": _("Repository management tool was not recognized for your system."),
>       "KCHREPOS0015E": _("There is no YUM configuration directory."),
>       "KCHREPOS0016E": _("There are no parameters to create a new repo file."),
>       "KCHREPOS0017E": _("Could not write repo file %(repo_file)s"),
> diff --git a/src/kimchi/model/host.py b/src/kimchi/model/host.py
> index a7db7c9..b195a97 100644
> --- a/src/kimchi/model/host.py
> +++ b/src/kimchi/model/host.py
> @@ -310,12 +310,21 @@ class PackageUpdateModel(object):
>
>   class RepositoriesModel(object):
>       def __init__(self, **kargs):
> -        self.host_repositories = Repositories()
> +        try:
> +            self.host_repositories = Repositories()
> +        except:
> +            self.host_repositories = None
>
>       def get_list(self):
> +        if self.host_repositories is None:
> +            raise InvalidOperation('KCHREPOS0014E')
> +
>           return self.host_repositories.getRepositories().keys()
>
>       def create(self, params):
> +        if self.host_repositories is None:
> +            raise InvalidOperation('KCHREPOS0014E')
> +
>           repo_id = params.get('repo_id', None)
>
>           # Create a repo_id if not given by user. The repo_id will follow
> @@ -335,20 +344,35 @@ class RepositoriesModel(object):
>
>   class RepositoryModel(object):
>       def __init__(self, **kargs):
> -        self._repositories = Repositories()
> +        try:
> +            self._repositories = Repositories()
> +        except:
> +            self._repositories = None
>
>       def lookup(self, repo_id):
> +        if self._repositories is None:
> +            raise InvalidOperation('KCHREPOS0014E')
> +
>           return self._repositories.getRepository(repo_id)
>
>       def enable(self, repo_id):
> +        if self._repositories is None:
> +            raise InvalidOperation('KCHREPOS0014E')
> +
>           if not self._repositories.enableRepository(repo_id):
>               raise OperationFailed("KCHREPOS0007E", {'repo_id': repo_id})
>
>       def disable(self, repo_id):
> +        if self._repositories is None:
> +            raise InvalidOperation('KCHREPOS0014E')
> +
>           if not self._repositories.disableRepository(repo_id):
>               raise OperationFailed("KCHREPOS0008E", {'repo_id': repo_id})
>
>       def update(self, repo_id, params):
> +        if self._repositories is None:
> +            raise InvalidOperation('KCHREPOS0014E')
> +
>           try:
>               self._repositories.updateRepository(repo_id, params)
>           except:
> @@ -356,4 +380,7 @@ class RepositoryModel(object):
>           return repo_id
>
>       def delete(self, repo_id):
> +        if self._repositories is None:
> +            raise InvalidOperation('KCHREPOS0014E')
> +
>           return self._repositories.removeRepository(repo_id)


-- 
Adam King <rak at linux.vnet.ibm.com>
IBM CSI




More information about the Kimchi-devel mailing list