本文整理汇总了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
示例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, '')
示例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)
示例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
示例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)
示例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)
示例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})
示例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
示例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
示例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
示例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.')
示例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)
示例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
示例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)
示例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