def createSettingsFile(): """ Creates the default settings file, if it doesn't exists. """ # Check if the settings file exists try: with open(SETTINGS_PATH): pass except IOError: # No, settings file. Create the file and load the default settings. file = open(SETTINGS_PATH, 'w+') file.close() alp.writePlist(DEFAULT_SETTINGS, SETTINGS_PATH)
def setKeyChainPassword(password): keychain = alp.Keychain(alp.bundle()) settings = alp.readPlist(SETTINGS_PATH) username = settings["username"] if settings["passwordSet"] == "true": keychain.modifyPassword(username, password) else: keychain.storePassword(username, password) settings["passwordSet"] = "true" settings["credentialsChanged"] = "true" alp.writePlist(settings, SETTINGS_PATH)
def main(): """ Everything dispatches from this function. """ global settings # Create default settings if necessary createSettingsFile() # Read settings settings = alp.readPlist(SETTINGS_PATH) # Process the settings if settings["firstRun"] == "true": udpateDatabaseFromKippt() settings["firstRun"] = "false" settings["credentialsChanged"] = "false" alp.writePlist(settings, SETTINGS_PATH) elif settings["credentialsChanged"] == "true": udpateDatabaseFromKippt() settings["credentialsChanged"] = "false" alp.writePlist(settings, SETTINGS_PATH) elif settings["updateClips"] == "true": udpateDatabaseFromKippt() settings["updateClips"] = "false" alp.writePlist(settings, SETTINGS_PATH) # Get the keywords args = alp.args() if len(args) < 1: return # Execute the search items = search(args) if items is not None: alp.feedback(items) else: print "No items found"
def setUpdateDatabase(): settings = alp.readPlist(SETTINGS_PATH) settings["updateClips"] = "true" alp.writePlist(settings, SETTINGS_PATH)
def setUserName(username): settings = alp.readPlist(SETTINGS_PATH) settings["username"] = username settings["credentialsChanged"] = "true" alp.writePlist(settings, SETTINGS_PATH)