本文整理汇总了Python中munkilib.FoundationPlist类的典型用法代码示例。如果您正苦于以下问题:Python FoundationPlist类的具体用法?Python FoundationPlist怎么用?Python FoundationPlist使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FoundationPlist类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: findItemsToCheck
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,代码行数:20,代码来源:IconImporter.py
示例13: get_manifests
def get_manifests():
# TODO: Add handling similar to pkgsinfo for errors. Add errors
# to report.
manifest_dir = os.path.join(get_repo_path(), "manifests")
manifests = {}
for dirpath, dirnames, filenames in os.walk(manifest_dir):
for dirname in dirnames:
if dirname.startswith("."):
dirnames.remove(dirname)
for filename in filenames:
if filename not in IGNORED_FILES and not filename.startswith("."):
manifest_filename = os.path.join(dirpath, filename)
try:
manifests[manifest_filename] = FoundationPlist.readPlist(
manifest_filename)
except FoundationPlist.NSPropertyListSerializationException as err:
robo_print("Failed to open manifest '{}' with error "
"'{}'.".format(manifest_filename, err.message),
LogLevel.WARNING)
return manifests
开发者ID:sheagcraig,项目名称:Spruce-for-Munki,代码行数:21,代码来源:tools.py
示例14: len
Adds Internet Plug-Ins to the Application Inventory data that is gathered
by munki.
Thanks to Adam Reed and Josh Malone
"""
import os
import sys
sys.path.insert(0,'/usr/local/munki')
from munkilib import FoundationPlist
invPath = r"/Library/Managed Installs/ApplicationInventory.plist"
plugins = r"/Library/Internet Plug-Ins/"
directoryListing = os.listdir(plugins)
appinv = FoundationPlist.readPlist(invPath)
print "Adding %i plugins" % len(directoryListing)
for x in directoryListing:
path = os.path.join(plugins, x, 'Contents/Info.plist')
try:
info = FoundationPlist.readPlist(path)
plugin = {}
plugin['CFBundleName'] = info.get('CFBundleName', x)
plugin['bundleid'] = info.get('CFBundleIdentifier', 'N/A')
plugin['version'] = info.get('CFBundleVersion','N/A')
plugin['path'] = os.path.join(plugins, x)
plugin['name'] = info.get('CFBundleName', os.path.splitext(os.path.basename(x))[0])
appinv.append(plugin.copy())
except Exception, message:
开发者ID:grahamgilbert,项目名称:IT-CPE,代码行数:31,代码来源:inventory_add_plugins.py
示例15: exit
if options.checkstate:
updatecheck.MACHINE = munkicommon.getMachineFacts()
updatecheck.CONDITIONS = munkicommon.getConditions()
updatecheck.getCatalogs(cataloglist)
for check_item in options.checkstate:
installed_state = "unknown"
item_pl = updatecheck.getItemDetail(check_item, cataloglist)
if item_pl:
if updatecheck.installedState(item_pl):
installed_state = "installed"
exit_code = 0
else:
installed_state = "not installed"
exit_code = 1
print "%s: %s" % (check_item, installed_state)
exit(exit_code)
if not options.install and not options.uninstall:
exit()
manifest = {}
manifest["catalogs"] = cataloglist
manifest["managed_installs"] = options.install or []
manifest["managed_uninstalls"] = options.uninstall or []
FoundationPlist.writePlist(manifest, "/tmp/localmanifest.plist")
updatecheckresult = updatecheck.check(localmanifestpath="/tmp/localmanifest.plist")
if updatecheckresult == 1:
need_to_restart = installer.run()
if need_to_restart:
print "Please restart immediately!"
开发者ID:glarizza,项目名称:puppet-munki,代码行数:30,代码来源:munki_do.py
示例16: getiteminfo
def getiteminfo(itempath):
"""
Gets info for filesystem items passed to makecatalog item, to be used for
the "installs" key.
Determines if the item is an application, bundle, Info.plist, or a file or
directory and gets additional metadata for later comparison.
"""
infodict = {}
if munkicommon.isApplication(itempath):
infodict['type'] = 'application'
infodict['path'] = itempath
plist = getBundleInfo(itempath)
for key in ['CFBundleName', 'CFBundleIdentifier',
'CFBundleShortVersionString', 'CFBundleVersion']:
if key in plist:
infodict[key] = plist[key]
if 'LSMinimumSystemVersion' in plist:
infodict['minosversion'] = plist['LSMinimumSystemVersion']
elif 'SystemVersionCheck:MinimumSystemVersion' in plist:
infodict['minosversion'] = \
plist['SystemVersionCheck:MinimumSystemVersion']
else:
infodict['minosversion'] = '10.6'
elif os.path.exists(os.path.join(itempath, 'Contents', 'Info.plist')) or \
os.path.exists(os.path.join(itempath, 'Resources', 'Info.plist')):
infodict['type'] = 'bundle'
infodict['path'] = itempath
plist = getBundleInfo(itempath)
for key in ['CFBundleShortVersionString', 'CFBundleVersion']:
if key in plist:
infodict[key] = plist[key]
elif itempath.endswith("Info.plist") or \
itempath.endswith("version.plist"):
infodict['type'] = 'plist'
infodict['path'] = itempath
try:
plist = FoundationPlist.readPlist(itempath)
for key in ['CFBundleShortVersionString', 'CFBundleVersion']:
if key in plist:
infodict[key] = plist[key]
except FoundationPlist.NSPropertyListSerializationException:
pass
# let's help the admin -- if CFBundleShortVersionString is empty
# or doesn't start with a digit, and CFBundleVersion is there
# use CFBundleVersion as the version_comparison_key
if (not infodict.get('CFBundleShortVersionString') or
infodict['CFBundleShortVersionString'][0]
not in '0123456789'):
if infodict.get('CFBundleVersion'):
infodict['version_comparison_key'] = 'CFBundleVersion'
elif 'CFBundleShortVersionString' in infodict:
infodict['version_comparison_key'] = 'CFBundleShortVersionString'
if not 'CFBundleShortVersionString' in infodict and \
not 'CFBundleVersion' in infodict:
infodict['type'] = 'file'
infodict['path'] = itempath
if os.path.isfile(itempath):
infodict['md5checksum'] = munkicommon.getmd5hash(itempath)
return infodict
开发者ID:CLCMacTeam,项目名称:bigfiximport,代码行数:63,代码来源:bigfiximport.py
示例17: print
if item_pl:
if updatecheck.installedState(item_pl):
installed_state = "installed"
exit_code = 0
else:
installed_state = "not installed"
exit_code = 1
print("%s: %s") % (check_item, installed_state)
sys.exit(exit_code)
if not options.install and not options.uninstall:
sys.exit()
temp_dir = tempfile.mkdtemp()
temp_plist = temp_dir + "/localmanifest.plist"
manifest = {}
manifest["catalogs"] = cataloglist
manifest["managed_installs"] = options.install or []
manifest["managed_uninstalls"] = options.uninstall or []
FoundationPlist.writePlist(manifest, temp_plist)
updatecheckresult = updatecheck.check(localmanifestpath=temp_plist)
if updatecheckresult == 1:
need_to_restart = installer.run()
if need_to_restart:
print("Please restart immediately!")
try:
shutil.rmtree(temp_dir)
except OSError:
print("Could not remove temp directory")
开发者ID:natewalck,项目名称:puppet-munki,代码行数:30,代码来源:munki_do.py
示例18:
from munkilib import FoundationPlist, munkicommon
import os
from datetime import datetime
FILE_LOCATION = "/Users/Shared/.msc-dnd.plist"
# Does the file exist?
if not os.path.isfile(FILE_LOCATION):
# File isn't here, set the Munki pref to False
munkicommon.set_pref('SuppressUserNotification', False)
sys.exit(0)
# If it does, get the current date?
else:
plist = FoundationPlist.readPlist(FILE_LOCATION)
if 'DNDEndDate' not in plist:
# The key we need isn't in there, remove the file, set pref and exit
os.remove(FILE_LOCATION)
munkicommon.set_pref('SuppressUserNotification', False)
sys.exit(0)
else:
# Is the current date greater than the DND date?
saved_time = datetime.strptime(str(plist['DNDEndDate']), "%Y-%m-%d %H:%M:%S +0000")
current_time = datetime.now()
if saved_time < current_time:
# print "Current time is greater"
# If yes, remove the file and set the Munki pref for suppress notifications to False
os.remove(FILE_LOCATION)
munkicommon.set_pref('SuppressUserNotification', False)
sys.exit(0)
开发者ID:grahamgilbert,项目名称:munki-dnd,代码行数:31,代码来源:munki-dnd.py
示例19: get_all_catalog
def get_all_catalog():
"""Return the Munki 'all' catalog as a plist dict."""
munki_repo = get_repo_path()
all_path = os.path.join(munki_repo, "catalogs", "all")
return FoundationPlist.readPlist(all_path)
开发者ID:sheagcraig,项目名称:Spruce-for-Munki,代码行数:5,代码来源:tools.py
示例20: main
def main():
# Skip a manual check
if len(sys.argv) > 1:
if sys.argv[1] == 'manualcheck':
munkicommon.display_debug2("Manual check: skipping MunkiInfo Plugin")
exit(0)
prefs_to_get = [
'ManagedInstallDir',
'SoftwareRepoURL',
'ClientIdentifier',
'LogFile',
'LoggingLevel',
'LogToSyslog',
'InstallAppleSoftwareUpdates',
'AppleSoftwareUpdatesOnly',
'SoftwareUpdateServerURL',
'DaysBetweenNotifications',
'LastNotifiedDate',
'UseClientCertificate',
'SuppressUserNotification',
'SuppressAutoInstall',
'SuppressStopButtonOnInstall',
'PackageVerificationMode',
'FollowHTTPRedirects',
'UnattendedAppleUpdates',
'ClientCertificatePath',
'ClientKeyPath',
'LastAppleSoftwareUpdateCheck',
'LastCheckDate',
'LastCheckResult',
'LogFile',
'SoftwareRepoCACertificate',
'SoftwareRepoCAPath',
'PackageURL',
'CatalogURL',
'ManifestURL',
'IconURL',
'ClientResourceURL',
'ClientResourcesFilename',
'HelpURL',
'UseClientCertificateCNAsClientIdentifier',
'AdditionalHttpHeaders',
'SuppressLoginwindowInstall',
'InstallRequiresLogout',
'ShowRemovalDetail',
'MSULogEnabled',
'MSUDebugLogEnabled',
'LocalOnlyManifest',
'UnattendedAppleUpdates'
]
plist_path = '/usr/local/sal/plugin_results.plist'
if os.path.exists(plist_path):
plist = FoundationPlist.readPlist(plist_path)
else:
plist = []
result = {}
result['plugin'] = 'MunkiInfo'
result['historical'] = False
data = {}
for the_pref in prefs_to_get:
data[the_pref] = str(munkicommon.pref(the_pref))
result['data'] = data
plist.append(result)
FoundationPlist.writePlist(plist, plist_path)
开发者ID:arubdesu,项目名称:sal,代码行数:66,代码来源:munkiinfo.py
注:本文中的munkilib.FoundationPlist类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论