Exemplo n.º 1
0
def writePlist(timestamp, writePlistPath):
    sippysip = []
    if os.path.isfile(writePlistPath):
        sippysip = CFPreferencesCopyAppValue('Events', writePlistPath)
        if sippysip:
            sippysip = NSMutableArray.alloc().initWithArray_(sippysip)
        else:
            sippysip = []
        sippysip.append(timestamp)
        CFPreferencesSetAppValue('Events', sippysip, writePlistPath)
    else:
        sippysip.append(timestamp)
        CFPreferencesSetAppValue('Events', sippysip, writePlistPath)
Exemplo n.º 2
0
 def _set_macos_pref(self, key, value):
     """Sets a preference for domain"""
     try:
         CFPreferencesSetAppValue(key, value, BUNDLE_ID)
         if not CFPreferencesAppSynchronize(BUNDLE_ID):
             raise PreferenceError("Could not synchronize %s preference: %s" % key)
     except Exception as err:
         raise PreferenceError("Could not set %s preference: %s" % (key, err))
Exemplo n.º 3
0
 def _set_macos_pref(self, key, value):
     """Sets a preference for domain"""
     try:
         CFPreferencesSetAppValue(key, value, BUNDLE_ID)
         if not CFPreferencesAppSynchronize(BUNDLE_ID):
             raise PreferenceError(f"Could not synchronize preference {key}")
     except Exception as err:
         raise PreferenceError(f"Could not set {key} preference: {err}")
Exemplo n.º 4
0
def set_pref(key, value, domain=BUNDLE_ID):
    """Sets a preference for domain"""
    try:
        CFPreferencesSetAppValue(key, value, domain)
        if not CFPreferencesAppSynchronize(domain):
            raise PreferenceError("Could not synchronize %s preference: %s" %
                                  key)
    except Exception, err:
        raise PreferenceError("Could not set %s preference: %s" % (key, err))
Exemplo n.º 5
0
def set_app_pref(pref_name, value):
    """Sets a value in Preferences.
    Uses CoreFoundation.
    Args:
       pref_name: str preference name to set.
       value: value to set it to.
    """
    CFPreferencesSetAppValue(pref_name, value, BUNDLE_ID)
    CFPreferencesAppSynchronize(BUNDLE_ID)