@decorators.memoize
def _available_services():
 available_services = dict()
 for launch_dir in _launchd_paths():
  for (root, dirs, files) in os.walk(launch_dir):
   for file_name in files:
    if (not file_name.endswith('.plist')):
     continue
    file_path = os.path.join(root, file_name)
    true_path = os.path.realpath(file_path)
    if (not os.path.exists(true_path)):
     continue
    try:
     with salt.utils.fopen(file_path):
      plist = plistlib.readPlist(true_path)
    except Exception:
     cmd = '/usr/bin/plutil -convert xml1 -o - -- "{0}"'.format(true_path)
     plist_xml = __salt__['cmd.run'](cmd, output_loglevel='quiet')
     if six.PY2:
      plist = plistlib.readPlistFromString(plist_xml)
     else:
      plist = plistlib.readPlistFromBytes(salt.utils.to_bytes(plist_xml))
    try:
     available_services[plist.Label.lower()] = {'file_name': file_name, 'file_path': true_path, 'plist': plist}
    except AttributeError:
     available_services[os.path.basename(file_name).lower()] = {'file_name': file_name, 'file_path': true_path, 'plist': plist}
 return available_services

@ decorators . memoize def _available_services ( ) : available_services = dict ( ) for launch_dir in _launchd_paths ( ) : for ( root , dirs , files ) in os . walk ( launch_dir ) : for file_name in files : if ( not file_name . endswith ( '.plist' ) ) : continue file_path = os . path . join ( root , file_name ) true_path = os . path . realpath ( file_path ) if ( not os . path . exists ( true_path ) ) : continue try : with salt . utils . fopen ( file_path ) : plist = plistlib . readPlist ( true_path ) except Exception : cmd = '/usr/bin/plutil -convert xml1 -o - -- "{0}"' . format ( true_path ) plist_xml = __salt__ [ 'cmd.run' ] ( cmd , output_loglevel = 'quiet' ) if six . PY2 : plist = plistlib . readPlistFromString ( plist_xml ) else : plist = plistlib . readPlistFromBytes ( salt . utils . to_bytes ( plist_xml ) ) try : available_services [ plist . Label . lower ( ) ] = { 'file_name' : file_name , 'file_path' : true_path , 'plist' : plist } except AttributeError : available_services [ os . path . basename ( file_name ) . lower ( ) ] = { 'file_name' : file_name , 'file_path' : true_path , 'plist' : plist } return available_services
return a dictionary of all available services on the system .