當前位置: 首頁>>代碼示例>>Python>>正文


Python FoundationPlist.readPlist方法代碼示例

本文整理匯總了Python中munkilib.FoundationPlist.readPlist方法的典型用法代碼示例。如果您正苦於以下問題:Python FoundationPlist.readPlist方法的具體用法?Python FoundationPlist.readPlist怎麽用?Python FoundationPlist.readPlist使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在munkilib.FoundationPlist的用法示例。


在下文中一共展示了FoundationPlist.readPlist方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: checkForOSXFlashbackk

# 需要導入模塊: from munkilib import FoundationPlist [as 別名]
# 或者: from munkilib.FoundationPlist import readPlist [as 別名]
def checkForOSXFlashbackk():
	# Checks Various browsers for the malware
	browsersToCheck = ["Firefox.app", "Safari.app", "Opera.app", "Google Chrome.app"  "Camino.app", "Stainless.app", "OmniWebb.app", "Fluid.app"]
	userFilestoCheck = ["Library/LaunchAgents/com.sun.jsched.plist", ".jsched"]
	applicationsDirectory = "/Applications"
	plistLocation = "Contents/Info.plist"
	for browser in browsersToCheck:
		fullPathToPlist =  (os.path.join(applicationsDirectory, browser, plistLocation))
		if os.path.exists(fullPathToPlist):
			loadedPlist = FoundationPlist.readPlist(fullPathToPlist)
			malwareKey = loadedPlist.get("LSEnvironment", "")

			if malwareKey:
				return True

	# Check for malware in shared folder		
	if os.path.exists("/Users/Shared/.libgmalloc.dylib"):
		return True 

	# Check for malware in each user's folder
	for user in os.listdir("/Users/"):
		if not user.startswith('.'):
			fullPathToEnvPlist = (os.path.join("/Users", user, ".MacOSX", "environment.plist"))
			if os.path.exists(fullPathToEnvPlist):
				loadedPlist = FoundationPlist.readPlist(fullPathToEnvPlist)
				DYLDkey = loadedPlist.get("DYLD_INSERT_LIBRARIES", "")
				if DYLDkey:
					return True	
			for fileToCheck in userFilestoCheck:
			 	if os.path.exists((os.path.join("/Users", user, fileToCheck))):
					print os.path.join("/Users", user, fileToCheck)
			 		return True
	return False	
開發者ID:natewalck,項目名稱:Munki-Stuff,代碼行數:35,代碼來源:findJavaMalware.py

示例2: GetPlistValue

# 需要導入模塊: from munkilib import FoundationPlist [as 別名]
# 或者: from munkilib.FoundationPlist import readPlist [as 別名]
def GetPlistValue(key, secure=False, plist=None):
  """Returns the value of a given plist key.

  Args:
    key: string key to get from the plist.
    secure: boolean; True = munki secure plist, False = munki regular plist.
    plist: optional, str plist path to use, instead of Munki plist.
      Note, if plist is supplied, secure boolean is ignored.
  Returns:
    string value, or empty string if the key doesn't exist.
  """
  if not plist:
    if secure:
      plist = DEFAULT_SECURE_MANAGED_INSTALLS_PLIST_PATH
    else:
      plist = DEFAULT_MANAGED_INSTALLS_PLIST_PATH

  if OBJC_OK:
    pl = fpl.readPlist(plist)
    return pl.get(key, '')

  # get XML output of (potential) binary plist from plutil.
  exit_code, plist_xml, unused_err = Exec(
      ['/usr/bin/plutil', '-convert', 'xml1', '-o', '-', plist])
  if exit_code:
    logging.error('Failed to convert plist to xml1: %s', plist)
    return ''
  plist_contents = plistlib.readPlistFromString(plist_xml)
  return plist_contents.get(key, '')
開發者ID:Open-Source-GIS,項目名稱:simian,代碼行數:31,代碼來源:flight_common.py

示例3: main

# 需要導入模塊: from munkilib import FoundationPlist [as 別名]
# 或者: from munkilib.FoundationPlist import readPlist [as 別名]
def main():
    filevault = fv_status()

    mac_ver = mac_version()

    if LooseVersion("10.11") <= LooseVersion(mac_ver):
        sip = sip_status()
    else:
        sip = 'Not Supported'

    # Yes, I know it came in 10.7.5, but eh. I don't care, I'm lazy
    if LooseVersion("10.8") <= LooseVersion(mac_ver):
        gatekeeper = gatekeeper_status()
    else:
        gatekeeper = 'Not Supported'

    plist_path = '/usr/local/sal/plugin_results.plist'

    if os.path.exists(plist_path):
        plist = FoundationPlist.readPlist(plist_path)
    else:
        plist = []
    result = {}
    result['plugin'] = 'MachineDetailSecurity'
    result['historical'] = True
    data = {}

    data['Filevault'] = filevault
    data['SIP'] = sip
    data['Gatekeeper'] = gatekeeper
    result['data'] = data
    plist.append(result)
    FoundationPlist.writePlist(plist, plist_path)
開發者ID:erikng,項目名稱:sal,代碼行數:35,代碼來源:machinedetailsecurity.py

示例4: get_munkiimport_prefs

# 需要導入模塊: from munkilib import FoundationPlist [as 別名]
# 或者: from munkilib.FoundationPlist import readPlist [as 別名]
def get_munkiimport_prefs():
    """Get the current user's munkiimport preferences as plist dict."""
    try:
        prefs = FoundationPlist.readPlist(MUNKIIMPORT_PREFS)
    except NSPropertyListSerializationException:
        prefs = {}
    return prefs
開發者ID:sheagcraig,項目名稱:Spruce-for-Munki,代碼行數:9,代碼來源:tools.py

示例5: build_pkginfo_cache_with_errors

# 需要導入模塊: from munkilib import FoundationPlist [as 別名]
# 或者: from munkilib.FoundationPlist import readPlist [as 別名]
def build_pkginfo_cache_with_errors(repo):
    """Build a dictionary of pkgsinfo.

    Args:
        repo: String path to the base of a Munki repo.

    Returns:
        Tuple of:
            Dictionary of pkgsinfo with:
                key: path to pkginfo.
                val: pkginfo dictionary.
            Dictionary of errors with:
                key: path to pkginfo.
                val: Exception message.

    """
    pkginfos = {}
    errors = {}
    pkginfo_dir = os.path.join(repo, "pkgsinfo")
    for dirpath, _, filenames in os.walk(pkginfo_dir):
        for ifile in filter(is_pkginfo, filenames):
            path = os.path.join(dirpath, ifile)
            try:
                pkginfo_file = FoundationPlist.readPlist(path)
            except FoundationPlist.FoundationPlistException as error:
                errors[path] = error.message
                continue

            pkginfos[path] = pkginfo_file

    return (pkginfos, errors)
開發者ID:sheagcraig,項目名稱:Spruce-for-Munki,代碼行數:33,代碼來源:tools.py

示例6: GetAppleSUSCatalog

# 需要導入模塊: from munkilib import FoundationPlist [as 別名]
# 或者: from munkilib.FoundationPlist import readPlist [as 別名]
def GetAppleSUSCatalog():
  """Fetches an Apple Software Update Service catalog from the server."""
  url = GetServerURL()
  try:
    new = updatecheck.getResourceIfChangedAtomically(
        '%s/applesus/' % url, APPLE_SUS_CATALOG)
  except fetch.MunkiDownloadError:
    logging.exception('MunkiDownloadError getting Apple SUS catalog.')
    return

  if new:
    # SUS catalog changed, clear last check date to run softwareupdate soon.
    munkicommon.set_pref('LastAppleSoftwareUpdateCheck', None)

  try:
    sus_catalog = fpl.readPlist(APPLE_SUS_PLIST)
  except fpl.NSPropertyListSerializationException:
    # plist may not exist, but will be created when softwareupdate is run, then
    # the next execution of of this code will set the CatalogURL.
    logging.exception('Failed to read Apple SoftwareUpdate plist.')
    return

  # Update the CatalogURL setting in com.apple.SoftwareUpdate.plist.
  sus_catalog['CatalogURL'] = urlparse.urljoin(
      'file://localhost/', urllib.quote(APPLE_SUS_CATALOG))
  fpl.writePlist(sus_catalog, APPLE_SUS_PLIST)
開發者ID:Open-Source-GIS,項目名稱:simian,代碼行數:28,代碼來源:flight_common.py

示例7: main

# 需要導入模塊: from munkilib import FoundationPlist [as 別名]
# 或者: from munkilib.FoundationPlist import readPlist [as 別名]
def main():
    plist_path = (
        '/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/XProtect.meta.plist')
    if os.path.exists(plist_path):
        plist = FoundationPlist.readPlist(plist_path)
        version = str(plist['Version'])
    else:
        version = 'Not supported'

    add_plugin_results('XprotectVersion', {'Version': version})
開發者ID:bdemetris,項目名稱:sal,代碼行數:12,代碼來源:xprotectversion.py

示例8: pref

# 需要導入模塊: from munkilib import FoundationPlist [as 別名]
# 或者: from munkilib.FoundationPlist import readPlist [as 別名]
def pref(prefname):
    """Returns a preference for prefname"""
    try:
        _prefs = FoundationPlist.readPlist(PREFSPATH)
    except Exception:
        return None
    if prefname in _prefs:
        return _prefs[prefname]
    else:
        return None
開發者ID:autopkg,項目名稱:robperc-recipes,代碼行數:12,代碼來源:IconImporter.py

示例9: get_prefs

# 需要導入模塊: from munkilib import FoundationPlist [as 別名]
# 或者: from munkilib.FoundationPlist import readPlist [as 別名]
def get_prefs():
    # If prefs don't exist yet, offer to help create them.
    try:
        prefs = FoundationPlist.readPlist(SPRUCE_PREFS)
    except FoundationPlist.NSPropertyListSerializationException:
        prefs = None

    if not prefs or not prefs.get("repo_path"):
        prefs = build_prefs()

    return prefs
開發者ID:sheagcraig,項目名稱:Spruce-for-Munki,代碼行數:13,代碼來源:tools.py

示例10: GetManagedInstallReport

# 需要導入模塊: from munkilib import FoundationPlist [as 別名]
# 或者: from munkilib.FoundationPlist import readPlist [as 別名]
def GetManagedInstallReport(install_report_path=None):
  """Returns the ManagedInstallReport.plist plist object."""
  if not install_report_path:
    managed_installs_dir = munkicommon.pref('ManagedInstallDir')
    install_report_path = os.path.join(
        managed_installs_dir, 'ManagedInstallReport.plist')
  try:
    install_report = fpl.readPlist(install_report_path)
  except fpl.NSPropertyListSerializationException, e:
    logging.debug('Error reading %s : %s', install_report_path, str(e))
    return {}, install_report_path
開發者ID:Open-Source-GIS,項目名稱:simian,代碼行數:13,代碼來源:flight_common.py

示例11: GetAppleSUSCatalog

# 需要導入模塊: from munkilib import FoundationPlist [as 別名]
# 或者: from munkilib.FoundationPlist import readPlist [as 別名]
def GetAppleSUSCatalog():
  """Fetches an Apple Software Update Service catalog from the server."""
  url = GetServerURL()
  try:
    updatecheck.getResourceIfChangedAtomically(
        '%s/applesus/' % url, APPLE_SUS_CATALOG)
    # Update the CatalogURL setting in com.apple.SoftwareUpdate.plist.
    sus_catalog = fpl.readPlist(APPLE_SUS_PLIST)
    sus_catalog['CatalogURL'] = urlparse.urljoin(
        'file://localhost/', urllib.quote(APPLE_SUS_CATALOG))
    fpl.writePlist(sus_catalog, APPLE_SUS_PLIST)
  except (fetch.MunkiDownloadError, fpl.NSPropertyListSerializationException):
    logging.exception('MunkiDownloadError getting Apple SUS catalog.')
開發者ID:Equiem,項目名稱:simian-1,代碼行數:15,代碼來源:flight_common.py

示例12: main

# 需要導入模塊: from munkilib import FoundationPlist [as 別名]
# 或者: from munkilib.FoundationPlist import readPlist [as 別名]
def main():
    install_report_path = "/Library/Managed Installs/ManagedInstallReport.plist"
    install_report_data = plistlib.readPlist(install_report_path)

    install_end = install_report_data['EndTime']

    install_end_parsed = parser.parse(install_end)

    to_zone = tz.gettz(time.tzname[time.daylight])
    install_end_local = install_end_parsed.astimezone(to_zone)

    result_date_format = "%Y-%m-%d %H:%M:%S"
    install_end_date = install_end_local.strftime(result_date_format)

    extension_attribute = install_end_date
    print_extension_attribute(extension_attribute)
開發者ID:Jaharmi,項目名稱:extension_attribute,代碼行數:18,代碼來源:managedsoftwareupdate_install_end.py

示例13: getBundleInfo

# 需要導入模塊: from munkilib import FoundationPlist [as 別名]
# 或者: from munkilib.FoundationPlist import readPlist [as 別名]
def getBundleInfo(path):
    """
    Returns Info.plist data if available
    for bundle at path
    """
    infopath = os.path.join(path, "Contents", "Info.plist")
    if not os.path.exists(infopath):
        infopath = os.path.join(path, "Resources", "Info.plist")

    if os.path.exists(infopath):
        try:
            plist = FoundationPlist.readPlist(infopath)
            return plist
        except FoundationPlist.NSPropertyListSerializationException:
            pass

    return None
開發者ID:CLCMacTeam,項目名稱:bigfiximport,代碼行數:19,代碼來源:bigfiximport.py

示例14: main

# 需要導入模塊: from munkilib import FoundationPlist [as 別名]
# 或者: from munkilib.FoundationPlist import readPlist [as 別名]
def main():
    uptime_seconds = get_uptime()
    
    plist_path = '/usr/local/sal/plugin_results.plist'

    if os.path.exists(plist_path):
        plist = FoundationPlist.readPlist(plist_path)
    else:
        plist = []
    result = {}
    result['plugin'] = 'Uptime'
    result['historical'] = False
    data = {}
    
    data['UptimeDays'] = uptime_seconds / 60 / 60 / 24
    data['UptimeSeconds'] = uptime_seconds
    result['data'] = data
    plist.append(result)
    FoundationPlist.writePlist(plist, plist_path)
開發者ID:aschwanb,項目名稱:sal,代碼行數:21,代碼來源:uptime.py

示例15: findItemsToCheck

# 需要導入模塊: from munkilib import FoundationPlist [as 別名]
# 或者: from munkilib.FoundationPlist import readPlist [as 別名]
def findItemsToCheck(repo_path, itemlist=None):
    '''Builds a list of items to check; only the latest version
    of an item is retained. If itemlist is given, include items
    only on that list.'''
    all_catalog_path = os.path.join(repo_path, 'catalogs/all')
    catalogitems = FoundationPlist.readPlist(all_catalog_path)
    itemdb = {}
    for catalogitem in catalogitems:
        if itemlist and catalogitem['name'] not in itemlist:
            continue
        name = catalogitem['name']
        if name not in itemdb:
            itemdb[name] = catalogitem
        elif (munkicommon.MunkiLooseVersion(catalogitem['version'])
              > munkicommon.MunkiLooseVersion(itemdb[name]['version'])):
            itemdb[name] = catalogitem
    pkg_list = []
    for key in itemdb.keys():
        pkg_list.append(itemdb[key])
    return pkg_list
開發者ID:autopkg,項目名稱:robperc-recipes,代碼行數:22,代碼來源:IconImporter.py


注:本文中的munkilib.FoundationPlist.readPlist方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。