예제 #1
0
 def _present_selection(self, data):
     """
     Could not test: needs implementation
     """
     clear_screen()
     raise NotImplementedError(
         "MFA selections are not yet implemented, sorry.")
예제 #2
0
    def _get_institution(self):
        accounts = []
        total_institutions = len(self.available_institutions)
        for account in self.available_institutions:
            num, info = account
            accounts.append("{num:<4}{inst}".format(num=num,
                                                    inst=info['name']))

        institution_prompt = textwrap.dedent(
            """What bank is this account going to be for? \n{}\n\nEnter Number [q to quit]:"""
            .format('\n'.join(accounts)))

        clear_screen()

        res = prompt(institution_prompt,
                     validator=NumberValidator(
                         message="You must enter the chosen number",
                         allow_quit=True,
                         max_number=total_institutions))
        if res.isdigit():
            choice = int(res) - 1
        elif res.lower() == "q":
            choice = None

        return choice
예제 #3
0
 def _present_list(self, data):
     clear_screen()
     devices = list(enumerate(data, start=1))
     message = ["Where do you want to send the verification code:\n"]
     for i, d in devices:
         message.append("{:<4}{}\n".format(i, d["mask"]))
     message.append("\nEnter your selection: ")
     answer = prompt(
         "".join(message),
         validator=NumberValidator(
             message=
             "Enter the NUMBER where you want to send verification code",
             allow_quit=True,
             max_number=len(devices)))
     if answer.lower() == "q": return False  #we have abandoned ship
     dev = devices[int(answer) - 1][1]
     print("Code will be sent to: {}".format(dev["mask"]))
     self.connect_response = self.client.connect_step(
         self.account_type,
         None,
         options={'send_method': {
             'type': dev['type']
         }})
     code = prompt("Enter the code you received: ",
                   validator=NumberValidator())
     self.connect_response = self.client.connect_step(
         self.account_type, code)
     return True
예제 #4
0
 def _present_question(self, question):
     clear_screen()
     print(question[0])
     answer = prompt("Answer: ",
                     validator=NullValidator(
                         message="You must enter your answer",
                         allow_quit=True))
     if answer.lower() == "q": return False  #we have abandoned ship
     self.connect_response = self.client.connect_step(
         self.account_type, answer)
     return True
예제 #5
0
    def _present_accounts(self, data):
        clear_screen()
        accounts = list(enumerate(data, start=1))
        message = ["Which account do you want to add:\n"]
        for i, d in accounts:
            a = {}
            a['choice'] = str(i)
            a['name'] = d['meta']['name']
            a['type'] = d['subtype'] if 'subtype' in d else d['type']
            message.append("{choice:<2}. {name:<40}  {type}\n".format(**a))

        message.append("\nEnter your selection: ")
        answer = prompt(
            "".join(message),
            validator=NumberValidator(
                message="Enter the NUMBER of the account you want to add",
                allow_quit=True,
                max_number=len(accounts)))
        if answer.lower() == "q": return False  #we have abandoned ship
        self.selected_account = accounts[int(answer) - 1][1]
        return True
예제 #6
0
 def _get_needed_creds(self):
     credentials = self.active_institution["credentials"]
     clear_screen()
     print("Enter the required credentials for {}\n".format(
         self.active_institution["name"]))
     user_prompt = "Username ({}): ".format(credentials["username"])
     pass_prompt = "Password ({}): ".format(credentials["password"])
     pin = None
     username = prompt(
         user_prompt,
         validator=NullValidator(message="Please enter your username"))
     password = prompt(
         pass_prompt,
         is_password=True,
         validator=NullValidator(message="You must enter your password"))
     if "pin" in credentials:
         pin = prompt(
             "PIN: ",
             validator=NumLengthValidator(
                 message="Pin must be at least {} characters long"))
         if not bool(pin) or pin.lower() == "q":
             pin = None  #make sure we have something
     return username, password, pin
예제 #7
0
 def _get_needed_creds(self):
     credentials = self.active_institution['credentials']
     clear_screen()
     print('Enter the required credentials for {}\n'.format(
         self.active_institution['name']))
     user_prompt = 'Username ({}): '.format(credentials['username'])
     pass_prompt = 'Password ({}): '.format(credentials['password'])
     pin = None
     username = prompt(
         user_prompt,
         validator=NullValidator(message='Please enter your username'))
     password = prompt(
         pass_prompt,
         is_password=True,
         validator=NullValidator(message='You must enter your password'))
     if 'pin' in credentials:
         pin = prompt(
             'PIN: ',
             validator=NumLengthValidator(
                 message='Pin must be at least {} characters long'))
         if not bool(pin) or pin.lower() == 'q':
             pin = None  # Make sure we have something
     return username, password, pin