summaryrefslogtreecommitdiffstats
path: root/facts.py
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2015-02-23 20:42:49 +0100
committerJan Pokorný <jpokorny@redhat.com>2015-02-26 22:40:55 +0100
commit78f4a816f7db66a0896f60f6724d83f417101067 (patch)
treecda7b601cbc1ea0cdba4414cb04c7bfb1a1da94d /facts.py
parent48b641520ccc24add54b278c8fe56bc6ae153c8e (diff)
downloadclufter-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.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/facts.py b/facts.py
index a4c2d35..96687ec 100644
--- a/facts.py
+++ b/facts.py
@@ -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)