Created
July 7, 2011 04:11
-
-
Save SEJeff/1068876 to your computer and use it in GitHub Desktop.
API fix for apt.list_pkgs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jeff@desktopmonster:~/src/git/salt/salt/modules (misc-fixes)$ gdi apt.py | |
diff --git a/salt/modules/apt.py b/salt/modules/apt.py | |
index f3b0cd8..75751a4 100644 | |
--- a/salt/modules/apt.py | |
+++ b/salt/modules/apt.py | |
@@ -196,7 +196,7 @@ def upgrade(refresh=True): | |
return ret_pkgs | |
-def list_pkgs(regex_string=""): | |
+def list_pkgs(package_name="", regex_string=""): | |
''' | |
List the packages currently installed in a dict: | |
{'<package_name>': '<version>'} | |
@@ -205,12 +205,16 @@ def list_pkgs(regex_string=""): | |
salt '*' pkg.list_pkgs | |
''' | |
ret = {} | |
- cmd = 'dpkg --list ' + regex_string | |
+ cmd = 'dpkg --list ' + package_name | |
out = subprocess.Popen(cmd, | |
shell=True, | |
stdout=subprocess.PIPE).communicate()[0].split('\n') | |
+ if regex_string: | |
+ regex = re.compile(regex_string) | |
+ out = filter(regex.match, out) | |
+ | |
for line in out: | |
cols = line.split() | |
if len(cols) and cols[0].count('ii'): |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment