Example #1
0
    def get_nickname(self, args, fail_if_match=True, alt_text=False):
        if not args:
            while True:
                if alt_text:
                    nickname = input(
                        log.bold(
                            "Enter the name to add to the group (<enter>=done*, c=cancel) ? "
                        )).strip()
                else:
                    nickname = input(
                        log.bold("Enter name (c=cancel) ? ")).strip()

                if nickname.lower() == 'c':
                    print(log.red("Canceled"))
                    return ''

                if not nickname:
                    if alt_text:
                        return ''
                    else:
                        log.error("Name must not be blank.")
                        continue

                if fail_if_match:
                    if self.db.get(nickname) is not None:
                        log.error(
                            "Name already exists. Please choose a different name."
                        )
                        continue

                else:
                    if self.db.get(nickname) is None:
                        log.error(
                            "Name not found. Please enter a different name.")
                        continue

                break

        else:
            nickname = args.strip()

            if fail_if_match:
                if self.db.get(nickname) is not None:
                    log.error(
                        "Name already exists. Please choose a different name.")
                    return ''

            else:
                if self.db.get(nickname) is None:
                    log.error("Name not found. Please enter a different name.")
                    return ''

        return nickname
Example #2
0
    def get_groupname(self, args, fail_if_match=True, alt_text=False):
        all_groups = self.db.get_all_groups()

        if not args:
            while True:
                if alt_text:
                    groupname = input(log.bold("Enter the group to join (<enter>=done*, c=cancel) ? ")).strip()
                else:
                    groupname = input(log.bold("Enter the group (c=cancel) ? ")).strip()


                if groupname.lower() == 'c':
                    print(log.red("Canceled"))
                    return ''

                if not groupname:
                    if alt_text:
                        return ''
                    else:
                        log.error("The group name must not be blank.")
                        continue

                if groupname == 'All':
                    print("Cannot specify group 'All'. Please choose a different group.")
                    return ''

                if fail_if_match:
                    if groupname in all_groups:
                        log.error("Group already exists. Please choose a different group.")
                        continue

                else:
                    if groupname not in all_groups:
                        log.error("Group not found. Please enter a different group.")
                        continue

                break

        else:
            groupname = args.strip()

            if fail_if_match:
                if groupname in all_groups:
                    log.error("Group already exists. Please choose a different group.")
                    return ''

            else:
                if groupname not in all_groups:
                    log.error("Group not found. Please enter a different group.")
                    return ''

        return groupname
Example #3
0
    def get_groupname(self, args, fail_if_match=True, alt_text=False):
        all_groups = self.db.get_all_groups()

        if not args:
            while True:
                if alt_text:
                    groupname = input(log.bold("Enter the group to join (<enter>=done*, c=cancel) ? ")).strip()
                else:
                    groupname = input(log.bold("Enter the group (c=cancel) ? ")).strip()


                if groupname.lower() == 'c':
                    print(log.red("Canceled"))
                    return ''

                if not groupname:
                    if alt_text:
                        return ''
                    else:
                        log.error("The group name must not be blank.")
                        continue

                if groupname == 'All':
                    print("Cannot specify group 'All'. Please choose a different group.")
                    return ''

                if fail_if_match:
                    if groupname in all_groups:
                        log.error("Group already exists. Please choose a different group.")
                        continue

                else:
                    if groupname not in all_groups:
                        log.error("Group not found. Please enter a different group.")
                        continue

                break

        else:
            groupname = args.strip()

            if fail_if_match:
                if groupname in all_groups:
                    log.error("Group already exists. Please choose a different group.")
                    return ''

            else:
                if groupname not in all_groups:
                    log.error("Group not found. Please enter a different group.")
                    return ''

        return groupname
Example #4
0
    def get_nickname(self, args, fail_if_match=True, alt_text=False):
        if not args:
            while True:
                if alt_text:
                    nickname = input(log.bold("Enter the name to add to the group (<enter>=done*, c=cancel) ? ")).strip()
                else:
                    nickname = input(log.bold("Enter name (c=cancel) ? ")).strip()

                if nickname.lower() == 'c':
                    print(log.red("Canceled"))
                    return ''

                if not nickname:
                    if alt_text:
                        return ''
                    else:
                        log.error("Name must not be blank.")
                        continue


                if fail_if_match:
                    if self.db.get(nickname) is not None:
                        log.error("Name already exists. Please choose a different name.")
                        continue

                else:
                    if self.db.get(nickname) is None:
                        log.error("Name not found. Please enter a different name.")
                        continue

                break

        else:
            nickname = args.strip()

            if fail_if_match:
                if self.db.get(nickname) is not None:
                    log.error("Name already exists. Please choose a different name.")
                    return ''

            else:
                if self.db.get(nickname) is None:
                    log.error("Name not found. Please enter a different name.")
                    return ''

        return nickname
Example #5
0
            installed_printer_names = device.getSupportedCUPSPrinterNames(['hp'])
            # Check for duplicate names
            if (device_uri in installed_print_devices and printer_default_model in installed_print_devices[device_uri]) \
               or (printer_default_model in installed_printer_names):
                    i = 2
                    while True:
                        t = printer_default_model + "_%d" % i
                        if (t not in installed_printer_names) and(device_uri not in installed_print_devices or t not in installed_print_devices[device_uri]):
                            printer_default_model += "_%d" % i
                            break
                        i += 1

            if not auto:
                if printer_name is None:
                    while True:
                        printer_name = input(log.bold("\nPlease enter a name for this print queue (m=use model name:'%s'*, q=quit) ?" % printer_default_model))

                        if printer_name.lower().strip() == 'q':
                            log.info("OK, done.")
                            clean_exit(0)

                        if not printer_name or printer_name.lower().strip() == 'm':
                            printer_name = printer_default_model

                        name_ok = True

                        for d in list(installed_print_devices.keys()):
                            for p in installed_print_devices[d]:
                                if printer_name == p:
                                    log.error("A print queue with that name already exists. Please enter a different name.")
                                    name_ok = False
Example #6
0
            table.output()

            cont, ans = tui.enter_choice(
                "\nEnter option (d=download*, p=specify path, q=quit) ? ",
                ['d', 'p', 'q'], 'd')

            if not cont or ans == 'q':  # q
                clean_exit(0)

            if ans == 'd':  # d - download
                plugin_path = ""

            else:  # p - specify plugin path
                while True:
                    plugin_path = input(
                        log.bold(
                            "Enter the path to the 'hplip-%s-plugin.run' file (q=quit) : "
                            % version)).strip()

                    if plugin_path.strip().lower() == 'q':
                        clean_exit(1)

                    if plugin_path.startswith('http://'):
                        log.error("Plug-in filename =%s must be local file." %
                                  plugin_path)
                        continue

                    else:
                        plugin_path = os.path.normpath(
                            os.path.abspath(os.path.expanduser(plugin_path)))

                        if not os.path.exists(plugin_path):
Example #7
0
            clean_exit(0)

        if not services.close_running_hp_processes():
            clean_exit(1)

        if EXISTING_PACKAGE_PATH:
            downloaded_file = "%s/hplip-%s.run"%(EXISTING_PACKAGE_PATH, HPLIP_latest_ver)
            digsig_file = "%s/hplip-%s.run.asc"%(EXISTING_PACKAGE_PATH, HPLIP_latest_ver)
            PATH_TO_DOWNLOAD_INSTALLER = EXISTING_PACKAGE_PATH
        else:
            log.debug("\n Calling download_hplip_installer(...) \n")
            log.debug("\n System Time : %s \n"%datetime.datetime.now().time().isoformat())

            if not os.path.exists(PATH_TO_DOWNLOAD_INSTALLER):
                log.error(log.bold("No such file or directory%s"%PATH_TO_DOWNLOAD_INSTALLER))
                download_path = input(log.bold("Please specify the path to download. Press 'q' to quit:"))
                if download_path == 'q':
                    log.info("User selected to quit.")
                    clean_exit(1)            
                elif not os.path.exists(download_path):
                    log.error(log.bold("Specified path does not exist. Exiting...%s\n"%download_path)) 
                    clean_exit(1)
                elif not os.access(download_path, os.R_OK | os.W_OK):
                    log.error(log.bold("Specified path do not have enough permissions Exiting...%s\n"%download_path)) 
                    clean_exit(1)          
                else:
                    PATH_TO_DOWNLOAD_INSTALLER = download_path
            downloaded_file, digsig_file = download_hplip_installer(PATH_TO_DOWNLOAD_INSTALLER, HPLIP_latest_ver)


        gpg_obj = validation.GPG_Verification()
Example #8
0
            downloaded_file = "%s/hplip-%s.run" % (EXISTING_PACKAGE_PATH,
                                                   HPLIP_latest_ver)
            digsig_file = "%s/hplip-%s.run.asc" % (EXISTING_PACKAGE_PATH,
                                                   HPLIP_latest_ver)
            PATH_TO_DOWNLOAD_INSTALLER = EXISTING_PACKAGE_PATH
        else:
            log.debug("\n Calling download_hplip_installer(...) \n")
            log.debug("\n System Time : %s \n" %
                      datetime.datetime.now().time().isoformat())

            if not os.path.exists(PATH_TO_DOWNLOAD_INSTALLER):
                log.error(
                    log.bold("No such file or directory%s" %
                             PATH_TO_DOWNLOAD_INSTALLER))
                download_path = input(
                    log.bold(
                        "Please specify the path to download. Press 'q' to quit:"
                    ))
                if download_path == 'q':
                    log.info("User selected to quit.")
                    clean_exit(1)
                elif not os.path.exists(download_path):
                    log.error(
                        log.bold(
                            "Specified path does not exist. Exiting...%s\n" %
                            download_path))
                    clean_exit(1)
                elif not os.access(download_path, os.R_OK | os.W_OK):
                    log.error(
                        log.bold(
                            "Specified path do not have enough permissions Exiting...%s\n"
                            % download_path))
Example #9
0
def colorCal4():
    log.info(
        """Instructions:\n1. Hold the calibration page at arm's length in front of your eyes.
2. Tilt the page away from you. Look at the two large squares, each containing colored patches. For each large square, find the colored path that most closely matches the background color. Each patch has an associated letter and number.
""")
    values = [0, 0, 0, 0]
    ok = True
    while True:
        x = input(
            log.bold(
                """Enter the letter ('A' thru 'N') and number (1 thru 14) for the GRAY plot (eg, "C5") or "q" to quit: """
            ))

        if x.lower().strip() == 'q':
            ok = False
            break

        if x.lower().strip() == 'd':  # use defaults
            values[0], values[1] = -1, -1
            break

        if len(x) < 2:
            log.error(
                "You must enter at least two characters (a letter and a number)"
            )
            continue

        if len(x) > 3:
            log.error(
                'Enter only a single letter and a one or two digit number (eg, "C5").'
            )
            continue

        letter = x[0].lower()

        if letter not in 'abcdefghijklmn':
            log.error("You must enter a letter 'A' thru 'N'")
            continue

        try:
            number = int(x[1:])
        except ValueError:
            log.error(
                "You must enter a letter 'A' thru 'N' followed by a number 1 thru 14."
            )
            continue

        if number < 0 or number > 14:
            log.error(
                "You must enter a letter 'A' thru 'N' followed by a number 1 thru 14."
            )
            continue

        values[0] = ord(str(letter).upper()) - ord('A')
        values[1] = number - 1
        break

    if ok:
        while True:
            x = input(
                log.bold(
                    """Enter the letter ('P' thru 'V') and number (1 thru 7) for the COLOR plot (eg, "R3") or "q" to quit: """
                ))

            if x.lower().strip() == 'q':
                ok = False
                break

            if x.lower().strip() == 'd':  # use defaults
                values[2], values[3] = -1, -1
                break

            if len(x) < 2:
                log.error(
                    "You must enter at least two characters (a letter and a number)"
                )
                continue

            if len(x) > 3:
                log.error(
                    'Enter only a single letter and a one or two digit number (eg, "R3").'
                )
                continue

            letter = x[0].lower()

            if letter not in 'pqrstuv':
                log.error("You must enter a letter 'P' thru 'V'")
                continue

            try:
                number = int(x[1:])
            except ValueError:
                log.error(
                    "You must enter a letter 'P' thru 'V' followed by a number 1 thru 7."
                )
                continue

            if number < 0 or number > 7:
                log.error(
                    "You must enter a letter 'P' thru 'V' followed by a number 1 thru 7."
                )
                continue

            values[2] = ord(str(letter).upper()) - ord('P')
            values[3] = number - 1
            break

    return ok, values
Example #10
0
    def do_add(self, args):
        """
        Add an name.
        add [name]
        new [name]
        """
        nickname = self.get_nickname(args, fail_if_match=True)
        if not nickname: return

        print(log.bold("\nEnter information for %s:\n" % nickname))

#        title = raw_input(log.bold("Title (c=cancel) ? ")).strip()
#
#        if title.lower() == 'c':
#            print log.red("Canceled")
#            return
#
#        firstname = raw_input(log.bold("First name (c=cancel) ? ")).strip()
#
#        if firstname.lower() == 'c':
#            print log.red("Canceled")
#            return
#
#        lastname = raw_input(log.bold("Last name (c=cancel) ? ")).strip()
#
#        if lastname.lower() == 'c':
#            print log.red("Canceled")
#            return

        title = ''
        firstname = ''
        lastname = ''

        while True:
            faxnum = input(log.bold("Fax Number (c=cancel) ? ")).strip()

            if faxnum.lower() == 'c':
                print(log.red("Canceled"))
                return

            if not faxnum:
                log.error("Fax number must not be empty.")
                continue

            ok = True
            for c in faxnum:
                if c not in '0123456789-(+) *#':
                    log.error("Invalid characters in fax number. Fax number may only contain '0123456789-(+) *#'")
                    ok = False
                    break


            if ok: break

        notes = input(log.bold("Notes (c=cancel) ? ")).strip()

        if notes.strip().lower() == 'c':
            print(log.red("Canceled"))
            return

        groups = []
        all_groups = self.db.get_all_groups()
        while True:
            add_group = input(log.bold("Member of group (<enter>=done*, c=cancel) ? " )).strip()

            if add_group.lower() == 'c':
                print(log.red("Canceled"))
                return

            if not add_group:
                break

            if add_group == 'All':
                print(log.red("Cannot specify 'All'."))
                continue

            if add_group not in all_groups:
                log.warn("Group not found.")

                while True:
                    user_input = input(log.bold("Is this a new group (y=yes*, n=no) ? ")).lower().strip()

                    if user_input not in ['', 'n', 'y']:
                        log.error("Please enter 'y', 'n' or press <enter> for 'yes'.")
                        continue

                    break

                if user_input == 'n':
                    continue

            if add_group in groups:
                log.error("Group already specified. Choose a different group name or press <enter> to continue.")
                continue

            groups.append(add_group)

        groups.append('All')

        self.db.set(nickname, title, firstname, lastname, faxnum, groups, notes)
        self.do_show(nickname)
Example #11
0
    def do_edit(self, args):
        """
        Edit an name.
        edit [name]
        modify [name]
        """
        nickname = self.get_nickname(args, fail_if_match=False)
        if not nickname: return

        e = self.db.get(nickname)
        log.debug(e)

        print(log.bold("\nEdit/modify information for %s:\n" % nickname))

#        save_title = e['title']
#        title = raw_input(log.bold("Title (<enter>='%s', c=cancel) ? " % save_title)).strip()
#
#        if title.lower() == 'c':
#            print log.red("Canceled")
#            return
#
#        if not title:
#            title = save_title
#
#        save_firstname = e['firstname']
#        firstname = raw_input(log.bold("First name (<enter>='%s', c=cancel) ? " % save_firstname)).strip()
#
#        if firstname.lower() == 'c':
#            print log.red("Canceled")
#            return
#
#        if not firstname:
#            firstname = save_firstname
#
#        save_lastname = e['lastname']
#        lastname = raw_input(log.bold("Last name (<enter>='%s', c=cancel) ? " % save_lastname)).strip()
#
#        if lastname.lower() == 'c':
#            print log.red("Canceled")
#            return
#
#        if not lastname:
#            lastname = save_lastname

        lastname = ''
        firstname = ''
        title = ''

        save_faxnum = e['fax']
        while True:
            faxnum = input(log.bold("Fax Number (<enter>='%s', c=cancel) ? " % save_faxnum)).strip()

            if faxnum.lower() == 'c':
                print(log.red("Canceled"))
                return

            if not faxnum and not save_faxnum:
                log.error("Fax number must not be empty.")
                continue

            if not faxnum:
                faxnum = save_faxnum

            ok = True
            for c in faxnum:
                if c not in '0123456789-(+) *#':
                    log.error("Invalid characters in fax number. Fax number may only contain '0123456789-(+) '")
                    ok = False
                    break


            if ok: break

        save_notes = e['notes']
        notes = input(log.bold("Notes (<enter>='%s', c=cancel) ? " % save_notes)).strip()

        if notes.lower() == 'c':
            print(log.red("Canceled"))
            return

        if not notes:
            notes = save_notes

        if e['groups']:
            print("\nLeave or Stay in a Group:\n")

        new_groups = []
        for g in e['groups']:
            if g == 'All':
                continue

            ok, ans = tui.enter_yes_no("Stay in group %s " % g,
                choice_prompt="(y=yes* (stay), n=no (leave), c=cancel) ? ")

            if not ok:
                print(log.red("Canceled"))
                return

            if ans:
                new_groups.append(g)

        print("\nJoin New Group(s):\n")

        while True:
            add_group = self.get_groupname('', fail_if_match=False, alt_text=True)

            if add_group.lower() == 'c':
                print(log.red("Canceled"))
                return

            if not add_group:
                break

            all_groups = self.db.get_all_groups()

            if add_group not in all_groups:
                log.warn("Group not found.")
                ok, ans = tui.enter_yes_no("Is this a new group",
                    choice_prompt="(y=yes* (new), n=no, c=cancel) ? ")

                if not ok:
                    print(log.red("Canceled"))
                    return

                if not ans:
                    continue

            if add_group in e['groups']:
                log.error("Group already specified. Choose a different group name or press <enter> to continue.")
                continue

            new_groups.append(add_group)

        self.db.set(nickname, title, firstname, lastname, faxnum, new_groups, notes)
        self.do_show(nickname)

        print()
Example #12
0
def colorCal4():
    log.info("""Instructions:\n1. Hold the calibration page at arm's length in front of your eyes.
2. Tilt the page away from you. Look at the two large squares, each containing colored patches. For each large square, find the colored path that most closely matches the background color. Each patch has an associated letter and number.
""")
    values = [0, 0, 0, 0]
    ok = True
    while True:
        x = input(log.bold("""Enter the letter ('A' thru 'N') and number (1 thru 14) for the GRAY plot (eg, "C5") or "q" to quit: """))

        if x.lower().strip() == 'q':
            ok = False
            break

        if x.lower().strip() == 'd': # use defaults
            values[0], values[1] = -1, -1
            break

        if len(x) < 2:
            log.error("You must enter at least two characters (a letter and a number)")
            continue

        if len(x) > 3:
            log.error('Enter only a single letter and a one or two digit number (eg, "C5").')
            continue

        letter = x[0].lower()

        if letter not in 'abcdefghijklmn':
            log.error("You must enter a letter 'A' thru 'N'")
            continue

        try:
            number = int(x[1:])
        except ValueError:
            log.error("You must enter a letter 'A' thru 'N' followed by a number 1 thru 14.")
            continue

        if number < 0 or number > 14:
            log.error("You must enter a letter 'A' thru 'N' followed by a number 1 thru 14.")
            continue

        values[0] = ord(str(letter).upper()) - ord('A')
        values[1] = number - 1
        break

    if ok:
        while True:
            x = input(log.bold("""Enter the letter ('P' thru 'V') and number (1 thru 7) for the COLOR plot (eg, "R3") or "q" to quit: """))

            if x.lower().strip() == 'q':
                ok = False
                break

            if x.lower().strip() == 'd': # use defaults
                values[2], values[3] = -1, -1
                break

            if len(x) < 2:
                log.error("You must enter at least two characters (a letter and a number)")
                continue

            if len(x) > 3:
                log.error('Enter only a single letter and a one or two digit number (eg, "R3").')
                continue

            letter = x[0].lower()

            if letter not in 'pqrstuv':
                log.error("You must enter a letter 'P' thru 'V'")
                continue

            try:
                number = int(x[1:])
            except ValueError:
                log.error("You must enter a letter 'P' thru 'V' followed by a number 1 thru 7.")
                continue

            if number < 0 or number > 7:
                log.error("You must enter a letter 'P' thru 'V' followed by a number 1 thru 7.")
                continue

            values[2] = ord(str(letter).upper()) - ord('P')
            values[3] = number - 1
            break

    return ok, values
Example #13
0
    def do_add(self, args):
        """
        Add an name.
        add [name]
        new [name]
        """
        nickname = self.get_nickname(args, fail_if_match=True)
        if not nickname: return

        print(log.bold("\nEnter information for %s:\n" % nickname))

#        title = raw_input(log.bold("Title (c=cancel) ? ")).strip()
#
#        if title.lower() == 'c':
#            print log.red("Canceled")
#            return
#
#        firstname = raw_input(log.bold("First name (c=cancel) ? ")).strip()
#
#        if firstname.lower() == 'c':
#            print log.red("Canceled")
#            return
#
#        lastname = raw_input(log.bold("Last name (c=cancel) ? ")).strip()
#
#        if lastname.lower() == 'c':
#            print log.red("Canceled")
#            return

        title = ''
        firstname = ''
        lastname = ''

        while True:
            faxnum = input(log.bold("Fax Number (c=cancel) ? ")).strip()

            if faxnum.lower() == 'c':
                print(log.red("Canceled"))
                return

            if not faxnum:
                log.error("Fax number must not be empty.")
                continue

            ok = True
            for c in faxnum:
                if c not in '0123456789-(+) *#':
                    log.error("Invalid characters in fax number. Fax number may only contain '0123456789-(+) *#'")
                    ok = False
                    break


            if ok: break

        notes = input(log.bold("Notes (c=cancel) ? ")).strip()

        if notes.strip().lower() == 'c':
            print(log.red("Canceled"))
            return

        groups = []
        all_groups = self.db.get_all_groups()
        while True:
            add_group = input(log.bold("Member of group (<enter>=done*, c=cancel) ? " )).strip()

            if add_group.lower() == 'c':
                print(log.red("Canceled"))
                return

            if not add_group:
                break

            if add_group == 'All':
                print(log.red("Cannot specify 'All'."))
                continue

            if add_group not in all_groups:
                log.warn("Group not found.")

                while True:
                    user_input = input(log.bold("Is this a new group (y=yes*, n=no) ? ")).lower().strip()

                    if user_input not in ['', 'n', 'y']:
                        log.error("Please enter 'y', 'n' or press <enter> for 'yes'.")
                        continue

                    break

                if user_input == 'n':
                    continue

            if add_group in groups:
                log.error("Group already specified. Choose a different group name or press <enter> to continue.")
                continue

            groups.append(add_group)

        groups.append('All')

        self.db.set(nickname, title, firstname, lastname, faxnum, groups, notes)
        self.do_show(nickname)
Example #14
0
    def do_edit(self, args):
        """
        Edit an name.
        edit [name]
        modify [name]
        """
        nickname = self.get_nickname(args, fail_if_match=False)
        if not nickname: return

        e = self.db.get(nickname)
        log.debug(e)

        print(log.bold("\nEdit/modify information for %s:\n" % nickname))

#        save_title = e['title']
#        title = raw_input(log.bold("Title (<enter>='%s', c=cancel) ? " % save_title)).strip()
#
#        if title.lower() == 'c':
#            print log.red("Canceled")
#            return
#
#        if not title:
#            title = save_title
#
#        save_firstname = e['firstname']
#        firstname = raw_input(log.bold("First name (<enter>='%s', c=cancel) ? " % save_firstname)).strip()
#
#        if firstname.lower() == 'c':
#            print log.red("Canceled")
#            return
#
#        if not firstname:
#            firstname = save_firstname
#
#        save_lastname = e['lastname']
#        lastname = raw_input(log.bold("Last name (<enter>='%s', c=cancel) ? " % save_lastname)).strip()
#
#        if lastname.lower() == 'c':
#            print log.red("Canceled")
#            return
#
#        if not lastname:
#            lastname = save_lastname

        lastname = ''
        firstname = ''
        title = ''

        save_faxnum = e['fax']
        while True:
            faxnum = input(log.bold("Fax Number (<enter>='%s', c=cancel) ? " % save_faxnum)).strip()

            if faxnum.lower() == 'c':
                print(log.red("Canceled"))
                return

            if not faxnum and not save_faxnum:
                log.error("Fax number must not be empty.")
                continue

            if not faxnum:
                faxnum = save_faxnum

            ok = True
            for c in faxnum:
                if c not in '0123456789-(+) *#':
                    log.error("Invalid characters in fax number. Fax number may only contain '0123456789-(+) '")
                    ok = False
                    break


            if ok: break

        save_notes = e['notes']
        notes = input(log.bold("Notes (<enter>='%s', c=cancel) ? " % save_notes)).strip()

        if notes.lower() == 'c':
            print(log.red("Canceled"))
            return

        if not notes:
            notes = save_notes

        if e['groups']:
            print("\nLeave or Stay in a Group:\n")

        new_groups = []
        for g in e['groups']:
            if g == 'All':
                continue

            ok, ans = tui.enter_yes_no("Stay in group %s " % g,
                choice_prompt="(y=yes* (stay), n=no (leave), c=cancel) ? ")

            if not ok:
                print(log.red("Canceled"))
                return

            if ans:
                new_groups.append(g)

        print("\nJoin New Group(s):\n")

        while True:
            add_group = self.get_groupname('', fail_if_match=False, alt_text=True)

            if add_group.lower() == 'c':
                print(log.red("Canceled"))
                return

            if not add_group:
                break

            all_groups = self.db.get_all_groups()

            if add_group not in all_groups:
                log.warn("Group not found.")
                ok, ans = tui.enter_yes_no("Is this a new group",
                    choice_prompt="(y=yes* (new), n=no, c=cancel) ? ")

                if not ok:
                    print(log.red("Canceled"))
                    return

                if not ans:
                    continue

            if add_group in e['groups']:
                log.error("Group already specified. Choose a different group name or press <enter> to continue.")
                continue

            new_groups.append(add_group)

        self.db.set(nickname, title, firstname, lastname, faxnum, new_groups, notes)
        self.do_show(nickname)

        print()
Example #15
0
            table.output()

            cont, ans = tui.enter_choice("\nEnter option (d=download*, p=specify path, q=quit) ? ",
                ['d', 'p','q'], 'd')

            if not cont or ans == 'q': # q
                clean_exit(0)


            if ans == 'd': # d - download
                plugin_path = ""

            else : # p - specify plugin path
                while True:
                    plugin_path = input(log.bold("Enter the path to the 'hplip-%s-plugin.run' file (q=quit) : " %
                        version)).strip()

                    if plugin_path.strip().lower() == 'q':
                        clean_exit(1)

                    if  plugin_path.startswith('http://'):
                        log.error("Plug-in filename =%s must be local file." % plugin_path)
                        continue

                    else:
                        plugin_path = os.path.normpath(os.path.abspath(os.path.expanduser(plugin_path)))

                        if not os.path.exists(plugin_path):
                            log.error("Plug-in path '%s' not found." % plugin_path)
                            continue