Esempio n. 1
0
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)
Esempio n. 2
0
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)
Esempio n. 3
0
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)
Esempio n. 4
0
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"
Esempio n. 5
0
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"
Esempio n. 6
0
def setUpdateDatabase():
    settings = alp.readPlist(SETTINGS_PATH)
    settings["updateClips"] = "true"
    alp.writePlist(settings, SETTINGS_PATH)
Esempio n. 7
0
def setUserName(username):
    settings = alp.readPlist(SETTINGS_PATH)
    settings["username"] = username
    settings["credentialsChanged"] = "true"
    alp.writePlist(settings, SETTINGS_PATH)