当前位置: 首页>>代码示例>>Python>>正文


Python FoundationPlist.writePlist方法代码示例

本文整理汇总了Python中munkilib.FoundationPlist.writePlist方法的典型用法代码示例。如果您正苦于以下问题:Python FoundationPlist.writePlist方法的具体用法?Python FoundationPlist.writePlist怎么用?Python FoundationPlist.writePlist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在munkilib.FoundationPlist的用法示例。


在下文中一共展示了FoundationPlist.writePlist方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GetAppleSUSCatalog

# 需要导入模块: from munkilib import FoundationPlist [as 别名]
# 或者: from munkilib.FoundationPlist import writePlist [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

示例2: main

# 需要导入模块: from munkilib import FoundationPlist [as 别名]
# 或者: from munkilib.FoundationPlist import writePlist [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

示例3: GetAppleSUSCatalog

# 需要导入模块: from munkilib import FoundationPlist [as 别名]
# 或者: from munkilib.FoundationPlist import writePlist [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

示例4: build_prefs

# 需要导入模块: from munkilib import FoundationPlist [as 别名]
# 或者: from munkilib.FoundationPlist import writePlist [as 别名]
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,代码行数:21,代码来源:tools.py

示例5: UploadAllManagedInstallReports

# 需要导入模块: from munkilib import FoundationPlist [as 别名]
# 或者: from munkilib.FoundationPlist import writePlist [as 别名]
def UploadAllManagedInstallReports(on_corp, logout=False):
  """Uploads any installs, updates, uninstalls back to Simian server.

  If no reports of installs/updates/uninstalls exist to report,
  then this function only contacts the server if logout is True.

  Args:
    on_corp: str, on_corp status from GetClientIdentifier.
    logout: bool, default False, whether to logout or not when finished.
  """
  # Report installs from the ManagedInstallsReport archives.
  archives_dir = os.path.join(munkicommon.pref('ManagedInstallDir'), 'Archives')
  if os.path.isdir(archives_dir):
    for fname in os.listdir(archives_dir):
      if not fname.startswith('ManagedInstallReport-'):
        continue
      install_report_path = os.path.join(archives_dir, fname)
      if not os.path.isfile(install_report_path):
        continue
      install_report, _ = GetManagedInstallReport(
          install_report_path=install_report_path)
      try:
        _UploadManagedInstallReport(on_corp, install_report)
        try:
          os.unlink(install_report_path)
        except (IOError, OSError):
          logging.warning(
              'Failed to delete ManagedInstallsReport.plist: %s',
              install_report_path)
      except ServerRequestError:
        logging.exception('Error uploading ManagedInstallReport installs.')

  # Report installs from the current ManagedInstallsReport.plist.
  install_report, install_report_path = GetManagedInstallReport()
  try:
    _UploadManagedInstallReport(on_corp, install_report, logout=logout)
    # Clear reportable information now that is has been published.
    install_report['InstallResults'] = []
    install_report['RemovalResults'] = []
    install_report['ProblemInstalls'] = []
    fpl.writePlist(install_report, install_report_path)
  except ServerRequestError:
    logging.exception('Error uploading ManagedInstallReport installs.')
开发者ID:Equiem,项目名称:simian-1,代码行数:45,代码来源:flight_common.py

示例6: main

# 需要导入模块: from munkilib import FoundationPlist [as 别名]
# 或者: from munkilib.FoundationPlist import writePlist [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

示例7: add_plugin_results

# 需要导入模块: from munkilib import FoundationPlist [as 别名]
# 或者: from munkilib.FoundationPlist import writePlist [as 别名]
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,代码行数:22,代码来源:munkiinfo.py

示例8: UploadAllManagedInstallReports

# 需要导入模块: from munkilib import FoundationPlist [as 别名]
# 或者: from munkilib.FoundationPlist import writePlist [as 别名]
def UploadAllManagedInstallReports(client, on_corp):
  """Uploads any installs, updates, uninstalls back to Simian server.

  Args:
    client: A SimianAuthClient.
    on_corp: str, on_corp status from GetClientIdentifier.
  """
  # Report installs from the ManagedInstallsReport archives.
  archives_dir = os.path.join(munkicommon.pref('ManagedInstallDir'), 'Archives')
  if os.path.isdir(archives_dir):
    for fname in os.listdir(archives_dir):
      if not fname.startswith('ManagedInstallReport-'):
        continue
      install_report_path = os.path.join(archives_dir, fname)
      if not os.path.isfile(install_report_path):
        continue
      install_report, _ = GetManagedInstallReport(
          install_report_path=install_report_path)
      try:
        _UploadManagedInstallReport(client, on_corp, install_report)
        try:
          os.unlink(install_report_path)
        except (IOError, OSError):
          logging.warning(
              'Failed to delete ManagedInstallsReport.plist: %s',
              install_report_path)
      except ServerRequestError:
        logging.exception('Error uploading ManagedInstallReport installs.')

  # Report installs from the current ManagedInstallsReport.plist.
  install_report, install_report_path = GetManagedInstallReport()
  try:
    _UploadManagedInstallReport(client, on_corp, install_report)
    # Clear reportable information now that is has been published.
    install_report['InstallResults'] = []
    install_report['RemovalResults'] = []
    install_report['ProblemInstalls'] = []
    fpl.writePlist(install_report, install_report_path)
  except ServerRequestError:
    logging.exception('Error uploading ManagedInstallReport installs.')
开发者ID:Open-Source-GIS,项目名称:simian,代码行数:42,代码来源:flight_common.py

示例9: print

# 需要导入模块: from munkilib import FoundationPlist [as 别名]
# 或者: from munkilib.FoundationPlist import writePlist [as 别名]
        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,代码行数:32,代码来源:munki_do.py

示例10: main

# 需要导入模块: from munkilib import FoundationPlist [as 别名]
# 或者: from munkilib.FoundationPlist import writePlist [as 别名]
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,代码行数:68,代码来源:munkiinfo.py

示例11: exit

# 需要导入模块: from munkilib import FoundationPlist [as 别名]
# 或者: from munkilib.FoundationPlist import writePlist [as 别名]
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,代码行数:32,代码来源:munki_do.py

示例12: len

# 需要导入模块: from munkilib import FoundationPlist [as 别名]
# 或者: from munkilib.FoundationPlist import writePlist [as 别名]
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:
        pass

FoundationPlist.writePlist(appinv, invPath)
exit(0)
开发者ID:grahamgilbert,项目名称:IT-CPE,代码行数:32,代码来源:inventory_add_plugins.py


注:本文中的munkilib.FoundationPlist.writePlist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。