Ejemplo n.º 1
0
def confirm_delete(user):
    if input(f'\nyou are deleting {user.name} from the application.'
             ' Is this correct? [y/N] ').lower() != 'y':
        raise KeyboardInterrupt
    else:
        clear()
        print(f'{user.name} has been removed from registration')
Ejemplo n.º 2
0
def view(users):
    clear()
    print('#' * 80)
    print('#' + ' ' * 29 + 'Registered Accounts' + ' ' * 30 + '#')
    print('#' * 80)
    print(f'{users.count()} accounts(s) registered\n')
    for e, user in enumerate(users.all()):
        print(f'{e+1}. {user.name}')
Ejemplo n.º 3
0
def document(ini=False):
    for page_number, page in enumerate(pages):
        fill = 20 - len(page.split('\n'))
        clear()
        print(banner)
        print(page)
        if page_number == 10 and ini is True: 
            fill = intro(fill)
        input('\n'*fill+'press enter to continue...\n')
Ejemplo n.º 4
0
def prompt():
    ''' Top level prompt '''
    clear()
    print('#'*80)
    print('#' + ' '*21 +'Application OAuth Registration Menu'+ ' '*22 + '#')
    print('#'*80)
    return input('''
0: exit
1: add accounts
2: remove accounts
3: view registry

[select by number]: ''')
Ejemplo n.º 5
0
def select(user):
    while True:
        try:
            id = int(
                input('\nselect (by number) which account to delete. '
                      '(0 to exit): '))
            assert 0 <= id <= user.count()
        except (AssertionError, ValueError) as invalid:
            clear()
            print('selection must be a number in the list.')
            wait()
            view(user)
        else:
            if id is 0: raise KeyboardInterrupt
            else: return id
Ejemplo n.º 6
0
def add():
    
    user, request = User(), Requests()
   
    while request.is_invalid:
        user.populate_credentials()
        print('Validating the credentials may take a few minutes...\n')
        request(user)
        clear()

        # NOTE used for debugging
        #request._is_invalid = False #request(user)
        #user.name = 'ChrisHamberg'

        if request.is_invalid:
            try_again()
        else:
            user.lock()
            twitter._accounts.append(user)
            with database as session:
                session.add(user)
                session.commit()
            show_message(user)
Ejemplo n.º 7
0
def show_message(user):
    clear()
    print(f'{user.name} added to database registry.')
Ejemplo n.º 8
0
def try_again():
    if input(error_msg).lower() == 'n':  ### prompt the user.
        clear()
        print('Account registration process terminated.')
        raise KeyboardInterrupt
Ejemplo n.º 9
0
def main():
    from application.interactive import session
    clear(); print(banner)
    twitter = Twitter()
    application.interactive.session.twitter = twitter
    application.interactive.session.execute()
Ejemplo n.º 10
0
 def help(self):
     document()
     clear(); print(banner)
Ejemplo n.º 11
0
 def manage_accounts(self):
     ''' Provides an interface to the registry.database '''
     prompt.main(); clear()
     print(banner)