#NEWLINE# def list_pkgs( * packages ) : #NEWLINE# #INDENT# "\n    List the packages currently installed in a dict::\n\n        {'<package_name>': '<version>'}\n\n    External dependencies::\n\n        Virtual package resolution requires aptitude. Because this function\n        uses dpkg, virtual packages will be reported as not installed.\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' lowpkg.list_pkgs\n        salt '*' lowpkg.list_pkgs httpd\n    " #NEWLINE# pkgs = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# cmd = 'dpkg -l {0}' . format ( ' ' . join ( packages ) ) #NEWLINE# out = __salt__ [ 'cmd.run_all' ] ( cmd , python_shell = False ) #NEWLINE# if ( out [ 'retcode' ] != 0 ) : #NEWLINE# #INDENT# msg = ( 'Error:  ' + out [ 'stderr' ] ) #NEWLINE# log . error ( msg ) #NEWLINE# return msg #NEWLINE# #UNINDENT# out = out [ 'stdout' ] #NEWLINE# for line in out . splitlines ( ) : #NEWLINE# #INDENT# if line . startswith ( 'ii ' ) : #NEWLINE# #INDENT# comps = line . split ( ) #NEWLINE# pkgs [ comps [ 1 ] ] = comps [ 2 ] #NEWLINE# #UNINDENT# #UNINDENT# return pkgs