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


Python munkilib.FoundationPlist類代碼示例

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


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

示例1: main

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,代碼行數:33,代碼來源:machinedetailsecurity.py

示例2: checkForOSXFlashbackk

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,代碼行數:33,代碼來源:findJavaMalware.py

示例3: get_munkiimport_prefs

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,代碼行數:7,代碼來源:tools.py

示例4: build_pkginfo_cache_with_errors

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,代碼行數:31,代碼來源:tools.py

示例5: main

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,代碼行數:19,代碼來源:uptime.py

示例6: pref

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,代碼行數:10,代碼來源:IconImporter.py

示例7: main

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,代碼行數:10,代碼來源:xprotectversion.py

示例8: build_prefs

def build_prefs():
    # If munkiimport prefs exist, offer them as defaults.
    munkiimport_prefs = get_munkiimport_prefs()
    keys = ("repo_path", "repo_url")
    prefs = {}

    print ("No preference file was found for Spruce. Please allow me to "
           "break it down for you.")
    for key in keys:
        choice = None
        while choice is None:
            default = munkiimport_prefs.get(key, "")
            choice = raw_input(
                "Please enter a value for '{}' or hit enter to use the "
                "default value '{}': ".format(key, default))
        prefs[key] = choice if choice else default

    FoundationPlist.writePlist(prefs, SPRUCE_PREFS)
    return prefs
開發者ID:sheagcraig,項目名稱:Spruce-for-Munki,代碼行數:19,代碼來源:tools.py

示例9: get_prefs

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,代碼行數:11,代碼來源:tools.py

示例10: add_plugin_results

def add_plugin_results(plugin, data, historical=False):
    """Add data to the shared plugin results plist.

    This function creates the shared results plist file if it does not
    already exist; otherwise, it adds the entry by appending.

    Args:
        plugin (str): Name of the plugin returning data.
        data (dict): Dictionary of results.
        historical (bool): Whether to keep only one record (False) or
            all results (True). Optional, defaults to False.
    """
    plist_path = '/usr/local/sal/plugin_results.plist'
    if os.path.exists(plist_path):
        plugin_results = FoundationPlist.readPlist(plist_path)
    else:
        plugin_results = []

    plugin_results.append({'plugin': plugin, 'historical': historical, 'data': data})
    FoundationPlist.writePlist(plugin_results, plist_path)
開發者ID:bdemetris,項目名稱:sal,代碼行數:20,代碼來源:munkiinfo.py

示例11: getBundleInfo

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,代碼行數:17,代碼來源:bigfiximport.py

示例12: GetAppleSUSCatalog

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,代碼行數:26,代碼來源:flight_common.py

示例13: GetAppleSUSCatalog

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,代碼行數:13,代碼來源:flight_common.py

示例14: GetPlistValue

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,代碼行數:29,代碼來源:flight_common.py

示例15: get_pkgid_version

def get_pkgid_version(this_pkg_plist, this_pkg_id):
    if this_pkg_id in this_pkg_plist:
        cmd = [pkgutil_path, "--pkg-info-plist", this_pkg_id]
        cmd_output = subprocess.check_output(cmd)
        cmd_output_plist = plistlib.readPlistFromString(cmd_output)
        pkg_version = cmd_output_plist['pkg-version']
        return pkg_version
    else:
        return False
開發者ID:Jaharmi,項目名稱:extension_attribute,代碼行數:9,代碼來源:pkgid_version.py


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