Example #1
0
def edit_card():
    """
    Provide extra options to a card such as changing name after scanning a card.
    :return: None
    """

    opt_give_card_name = "Give this card a name."

    print("Please place the card you'd like to edit on the scanner.")
    card_uid, card_name = card_helper.wait_for_card()

    if card_name is None:
        print("Settings for card: %s" % card_uid)
    else:
        print("Settings for card %s (%s)" % (card_name, card_uid))
        opt_give_card_name = "Rename this card."

    print("")
    print("What would you like to do?")

    opts = [[opt_give_card_name, card_helper.name_card_ask_for_name]
            ]

    selected_item = select_from_options(opts)
    start_option(opts, selected_item - 1, parameters=card_uid)
    return
Example #2
0
def wait_for_card():
        card_helper.db.open_database()
        a, b = card_helper.wait_for_card()

        result = {
            "uid": a,
            "name": b
        }
        return result
Example #3
0
def read_card():
    """
    Option for user to select. Reads card and prints name.
    :return: None
    """
    if card_helper.is_linux:
        print("Please place an NFC device on the scanner.")
        print("")

        uid_found, card_name = card_helper.wait_for_card()

        if card_name is None:
            print("Device found: %s" % uid_found)
        else:
            print("Device found: %s (%s)" % (card_name, uid_found))
        print('')

    else:
        print("You must be on a linux device with a PN532 to do this.")
    return
Example #4
0
def add_automation():
    """
    Adds an automation to a card. May be PRINT, "PYTHON", or "HTMLREQ" (print, python script, or bash script)
    :return: None
    """
    print("Place the card you'd like to edit on the scanner.")

    uid, name = card_helper.wait_for_card()

    if name is None:
        print("Card selected: %s" % uid)
    else:
        print("Card selected: %s (%s)" % (name, uid))

    print("")
    print("What would you like this card to do?")
    automation_options = [
        ["Print a message", card_helper.add_automation_printmessage]
    ]

    selection = select_from_options(automation_options)
    start_option(automation_options, selection - 1, parameters=uid)
Example #5
0
def execute_automation():
    """
    Runs the automation assigned to a card if available.
    :return: None
    """
    print("Place the card you'd like to execute on the scanner.")

    uid, name = card_helper.wait_for_card()

    script_type, script = card_helper.db.get_script_for_card(uid)

    if script is None or script_type is None:
        if name is None:
            print("There was no automation assigned to %s" % uid)
        else:
            print("There was no automation assigned to %s (%s)" % (name, uid))
        return

    if script_type == "PRINT":
        print(script)
    else:
        print("This type isn't implemented yet. (%s)" % script_type)
Example #6
0
def check_for_card():
    uid, name = card_helper.wait_for_card()
    return uid, name