From 2e942c821ce92b7d9752e529a4e9b053e350bbee Mon Sep 17 00:00:00 2001 From: David Boucha Date: Mon, 18 Feb 2013 16:50:22 -0700 Subject: [PATCH] Use salt.utils.winapi.Com instead of manually --- salt/modules/win_pkg.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/salt/modules/win_pkg.py b/salt/modules/win_pkg.py index 43a5afddb3..d092ffc8f8 100644 --- a/salt/modules/win_pkg.py +++ b/salt/modules/win_pkg.py @@ -119,17 +119,16 @@ def list_pkgs(*args): salt '*' pkg.list_pkgs ''' - pythoncom.CoInitialize() - if len(args) == 0: - pkgs = dict( - list(_get_reg_software().items()) + - list(_get_msi_software().items())) - else: - # get package version for each package in *args - pkgs = {} - for arg in args: - pkgs.update(_search_software(arg)) - pythoncom.CoUninitialize() + with salt.utils.winapi.Com(): + if len(args) == 0: + pkgs = dict( + list(_get_reg_software().items()) + + list(_get_msi_software().items())) + else: + # get package version for each package in *args + pkgs = {} + for arg in args: + pkgs.update(_search_software(arg)) return pkgs