def format_time(timestamp=None): """Return timestamp as an ISO 8601 formatted string, in the current timezone. If timestamp isn't given the current time is used.""" if timestamp is None: return str(NSDate.new()) return str(NSDate.dateWithTimeIntervalSince1970_(timestamp))
def format_time(timestamp=None): """Return timestamp as an ISO 8601 formatted string, in the current timezone. If timestamp isn't given the current time is used.""" if timestamp is None: return str(NSDate.new()) else: return str(NSDate.dateWithTimeIntervalSince1970_(timestamp))
def pref(pref_name): """Return a preference. Since this uses CFPreferencesCopyAppValue, Preferences can be defined several places. Precedence is: - MCX/configuration profile - /var/root/Library/Preferences/ByHost/ManagedInstalls.XXXXXX.plist - /var/root/Library/Preferences/ManagedInstalls.plist - /Library/Preferences/ManagedInstalls.plist - default_prefs defined here. """ default_prefs = { 'ManagedInstallDir': '/Library/Managed Installs', 'SoftwareRepoURL': 'http://munki/repo', 'ClientIdentifier': '', 'LogFile': '/Library/Managed Installs/Logs/ManagedSoftwareUpdate.log', 'LoggingLevel': 1, 'LogToSyslog': False, 'InstallAppleSoftwareUpdates': False, 'AppleSoftwareUpdatesOnly': False, 'SoftwareUpdateServerURL': '', 'DaysBetweenNotifications': 1, 'LastNotifiedDate': NSDate.dateWithTimeIntervalSince1970_(0), 'UseClientCertificate': False, 'SuppressUserNotification': False, 'SuppressAutoInstall': False, 'SuppressStopButtonOnInstall': False, 'PackageVerificationMode': 'hash', 'FollowHTTPRedirects': 'none', 'UnattendedAppleUpdates': False, 'PerformAuthRestarts': False, } pref_value = CFPreferencesCopyAppValue(pref_name, BUNDLE_ID) if pref_value is None: pref_value = default_prefs.get(pref_name) # we're using a default value. We'll write it out to # /Library/Preferences/<BUNDLE_ID>.plist for admin # discoverability set_pref(pref_name, pref_value) if isinstance(pref_value, NSDate): # convert NSDate/CFDates to strings pref_value = str(pref_value) return pref_value
'AdditionalHttpHeaders': None, 'AppleSoftwareUpdatesOnly': False, 'CatalogURL': None, 'ClientCertificatePath': None, 'ClientIdentifier': '', 'ClientKeyPath': None, 'ClientResourcesFilename': None, 'ClientResourceURL': None, 'DaysBetweenNotifications': 1, 'FollowHTTPRedirects': 'none', 'HelpURL': None, 'IconURL': None, 'IgnoreSystemProxies': False, 'InstallRequiresLogout': False, 'InstallAppleSoftwareUpdates': False, 'LastNotifiedDate': NSDate.dateWithTimeIntervalSince1970_(0), 'LocalOnlyManifest': None, 'LogFile': '/Library/Managed Installs/Logs/ManagedSoftwareUpdate.log', 'LoggingLevel': 1, 'LogToSyslog': False, 'ManagedInstallDir': '/Library/Managed Installs', 'ManifestURL': None, 'PackageURL': None, 'PackageVerificationMode': 'hash', 'PerformAuthRestarts': False, 'RecoveryKeyFile': None, 'ShowOptionalInstallsForHigherOSVersions': False, 'SoftwareRepoCACertificate': None, 'SoftwareRepoCAPath': None, 'SoftwareRepoURL': DEFAULT_INSECURE_REPO_URL, 'SoftwareUpdateServerURL': None,
'AdditionalHttpHeaders': None, 'AppleSoftwareUpdatesOnly': False, 'CatalogURL': None, 'ClientCertificatePath': None, 'ClientIdentifier': '', 'ClientKeyPath': None, 'ClientResourcesFilename': None, 'ClientResourceURL': None, 'DaysBetweenNotifications': 1, 'FollowHTTPRedirects': 'none', 'HelpURL': None, 'IconURL': None, 'IgnoreSystemProxies': False, 'InstallRequiresLogout': False, 'InstallAppleSoftwareUpdates': False, 'LastNotifiedDate': NSDate.dateWithTimeIntervalSince1970_(0), 'LocalOnlyManifest': None, 'LogFile': '/Library/Managed Installs/Logs/ManagedSoftwareUpdate.log', 'LoggingLevel': 1, 'LogToSyslog': False, 'ManagedInstallDir': '/Library/Managed Installs', 'ManifestURL': None, 'PackageURL': None, 'PackageVerificationMode': 'hash', 'PerformAuthRestarts': False, 'RecoveryKeyFile': None, 'ShowOptionalInstallsForHigherOSVersions': False, 'SoftwareRepoCACertificate': None, 'SoftwareRepoCAPath': None, 'SoftwareRepoURL': 'http://munki/repo', 'SoftwareUpdateServerURL': None,