diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2015-02-23 20:42:49 +0100 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2015-02-26 22:40:55 +0100 |
commit | 78f4a816f7db66a0896f60f6724d83f417101067 (patch) | |
tree | cda7b601cbc1ea0cdba4414cb04c7bfb1a1da94d /facts.py | |
parent | 48b641520ccc24add54b278c8fe56bc6ae153c8e (diff) | |
download | clufter-78f4a816f7db66a0896f60f6724d83f417101067.tar.gz clufter-78f4a816f7db66a0896f60f6724d83f417101067.tar.xz clufter-78f4a816f7db66a0896f60f6724d83f417101067.zip |
facts: cmd_pkg_install: be ready to deal with a generator
Also add relevant unit tests.
Reported-by: Patrik Hagara <phagara@redhat.com>
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'facts.py')
-rw-r--r-- | facts.py | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -1,5 +1,5 @@ # -*- coding: UTF-8 -*- -# Copyright 2014 Red Hat, Inc. +# Copyright 2015 Red Hat, Inc. # Part of clufter project # Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt) """Utility functions wrt. cluster systems in general""" @@ -379,12 +379,10 @@ def package(which, *sys_id): def cmd_pkg_install(pkgs, *sys_id): - cmd = '' - if pkgs: - cmd = _find_meta('cmd', 'pkg-install', *sys_id) or '' - if cmd: - cmd = cmd.format(packages=' '.join(pkgs)) - return cmd + # ready to deal with pkgs being a generator + cmd = _find_meta('cmd', 'pkg-install', *sys_id) + packages = ' '.join(pkgs) + return cmd.format(packages=packages) if cmd and packages else '' cluster_systems = (cluster_pcs_flatiron, cluster_pcs_needle) |