def runSelection(scr):
    """
    Print the selections and allow the user to select one
    """
    curses.use_default_colors()
    scr.erase()
    scr.move(0, 0)
    curses.curs_set(0)
    curses.noecho()

    width = scr.getmaxyx()[1]

    for header in CENTERED_HEADERS:
        centeredWrite(scr, header + '\n')

    for header in OTHER_HEADERS:
        slowWrite(scr, header + '\n')

    for i in xrange(width):
        scr.addch(curses.ACS_BSBS)
    scr.refresh()

    return makeSelection(scr)
示例#2
0
def runSelection(scr):
    """
    Print the selections and allow the user to select one
    """
    curses.use_default_colors()
    scr.erase()
    scr.move(0, 0)
    curses.curs_set(0)
    curses.noecho()

    width = scr.getmaxyx()[1]

    for header in CENTERED_HEADERS:
        centeredWrite(scr, header + '\n')

    for header in OTHER_HEADERS:
        slowWrite(scr, header + '\n')

    for i in xrange(width):
        scr.addch(curses.ACS_BSBS)
    scr.refresh()

    return makeSelection(scr)
def initScreen(scr):
    """
    Fill the screen to prepare for password entry
    
    scr - curses window returned from curses.initscr()
    """
    size = scr.getmaxyx()
    height = size[0]
    width = size[1]
    fillerHeight = height - HEADER_LINES

    hexes = generateHex(fillerHeight * 2)

    hexCol1 = hexes[:fillerHeight]
    hexCol2 = hexes[fillerHeight:]

    # generate the symbols and passwords
    fillerLength = width // 2 * fillerHeight
    passwords = getPasswords()
    filler = getFiller(fillerLength, passwords)
    fillerCol1 = filler[:len(filler) // 2]
    fillerCol2 = filler[len(filler) // 2:]
    
    # each column of symbols and passwords should be 1/4 of the screen
    fillerWidth = width // 4

    # print the header stuff
    slowWrite(scr, HEADER_TEXT)
    slowWrite(scr, '\nENTER PASSWORD NOW\n\n')
    slowWrite(scr, str(LOGIN_ATTEMPTS) + ' ATTEMPT(S) LEFT: ')
    for i in range(LOGIN_ATTEMPTS):
        scr.addch(curses.ACS_BLOCK)
        slowWrite(scr, ' ')
    slowWrite(scr, '\n\n')

    # print the hex and filler
    for i in range(fillerHeight):
        slowWrite(scr, "0x%X %s" % (hexCol1[i], fillerCol1[i * fillerWidth: (i + 1) * fillerWidth]), 1)
        if i < fillerHeight - 1:
            scr.addstr('\n')

    for i in range(fillerHeight):
        scr.move(HEADER_LINES + i, CONST_CHARS // 2 + fillerWidth)
        slowWrite(scr, '0x%X %s' % (hexCol2[i], fillerCol2[i * fillerWidth: (i + 1) * fillerWidth]), 1)

    scr.refresh()

    return passwords
示例#4
0
def runBoot(scr, hardMode):
    """
    Start the boot portion of the terminal

    hardMode - boolean indicating whether the user has to enter the ENTRY
               constants, or if they are entered automatically
    """
    curses.use_default_colors()
    scr.erase()
    scr.move(0, 0)

    curses.noecho()
    scr.scrollok(True)

    slowWrite(scr, MESSAGE_1 + '\n\n')

    if hardMode:
        # use must enter the correct text to proceed
        entry = ''
        while entry.upper() != ENTRY_1.upper():
            slowWrite(scr, '>')
            entry = upperInput(scr)
    else:
        # input is entered for them
        slowWrite(scr, '>')
        curses.napms(INPUT_PAUSE)
        slowWrite(scr, ENTRY_1 + '\n', TYPE_DELAY)

    slowWrite(scr, '\n' + MESSAGE_2 + '\n\n')

    if hardMode:
        entry = ''
        while entry.upper() != ENTRY_2.upper():
            slowWrite(scr, '>')
            entry = upperInput(scr)
        while entry.upper() != ENTRY_3.upper():
            slowWrite(scr, '>')
            entry = upperInput(scr)
    else:
        slowWrite(scr, '>')
        curses.napms(INPUT_PAUSE)
        slowWrite(scr, ENTRY_2 + '\n', TYPE_DELAY)
        slowWrite(scr, '>')
        curses.napms(INPUT_PAUSE)
        slowWrite(scr, ENTRY_3 + '\n', TYPE_DELAY)

    slowWrite(scr, '\n' + MESSAGE_3 + '\n\n')

    if hardMode:
        entry = ''
        while entry.upper() != ENTRY_4.upper():
            slowWrite(scr, '>')
            entry = upperInput(scr)
    else:
        slowWrite(scr, '>')
        curses.napms(INPUT_PAUSE)
        slowWrite(scr, ENTRY_4 + '\n', TYPE_DELAY)

    curses.napms(INPUT_PAUSE)
    return True
示例#5
0
def runLogin(scr, hardMode, username, password):
    """
    Start the login process

    hardMode - boolean indicating whether the user has to enter the username 
               and password or if they are entered automatically
    username - the username to log in
    password - the password to log in
    Returns true if hardMode == false or if the user entered the correct string
    """
    curses.use_default_colors()
    scr.erase()
    scr.move(0, 0)

    curses.noecho()
    scr.scrollok(True)

    slowWrite(scr, HEADER_TEXT + '\n\n')

    if hardMode:
        # use must enter the correct text to proceed
        entry = ''
        while entry.upper() != ENTRY.upper() + username.upper():
            slowWrite(scr, '> ')
            entry = upperInput(scr)
    else:
        # input is entered for them
        slowWrite(scr, '> ')
        curses.napms(INPUT_PAUSE)
        slowWrite(scr, ENTRY + username.upper() + '\n', TYPE_DELAY)

    slowWrite(scr, '\n' + PASSWORD_PROMPT + '\n\n')

    if hardMode:
        # use must enter the correct text to proceed
        entry = ''
        while entry.upper() != password.upper():
            if entry:
                slowWrite(scr, PASSWORD_ERROR + '\n\n')

            slowWrite(scr, '> ')
            entry = upperInput(scr, True)
    else:
        # input is entered for them
        slowWrite(scr, '> ')
        curses.napms(INPUT_PAUSE)
        password_stars = HIDDEN_MASK * len(password)
        slowWrite(scr, password_stars + '\n', TYPE_DELAY)

    curses.napms(500)
示例#6
0
def runLogin(scr, hardMode, username, password):
    """
    Start the login process

    hardMode - boolean indicating whether the user has to enter the username 
               and password or if they are entered automatically
    username - the username to log in
    password - the password to log in
    Returns true if hardMode == false or if the user entered the correct string
    """
    curses.use_default_colors()
    scr.erase()
    scr.move(0, 0)

    curses.noecho()
    scr.scrollok(True)

    slowWrite(scr, HEADER_TEXT + '\n\n')

    if hardMode:
        # use must enter the correct text to proceed
        entry = ''
        while entry.upper() != ENTRY.upper() + username.upper():
            slowWrite(scr, '> ')
            entry = upperInput(scr)
    else:
        # input is entered for them
        slowWrite(scr, '> ')
        curses.napms(INPUT_PAUSE)
        slowWrite(scr, ENTRY + username.upper() + '\n', TYPE_DELAY)

    slowWrite(scr, '\n' + PASSWORD_PROMPT + '\n\n')

    if hardMode:
        # use must enter the correct text to proceed
        entry = ''
        while entry.upper() != password.upper():
            if entry:
                slowWrite(scr, PASSWORD_ERROR + '\n\n')
            
            slowWrite(scr, '> ')
            entry = upperInput(scr, True)
    else:
        # input is entered for them
        slowWrite(scr, '> ')
        curses.napms(INPUT_PAUSE)
        password_stars = HIDDEN_MASK * len(password)
        slowWrite(scr, password_stars + '\n', TYPE_DELAY)

    curses.napms(500)
示例#7
0
def initScreen(scr):
    """
    Fill the screen to prepare for password entry
    
    scr - curses window returned from curses.initscr()
    """
    size = scr.getmaxyx()
    height = size[0]
    width = size[1]
    fillerHeight = height - HEADER_LINES

    hexes = generateHex(fillerHeight * 2)

    hexCol1 = hexes[:fillerHeight]
    hexCol2 = hexes[fillerHeight:]

    # generate the symbols and passwords
    fillerLength = width / 2 * fillerHeight
    passwords = getPasswords()
    filler = getFiller(fillerLength, passwords)
    fillerCol1 = filler[:len(filler) / 2]
    fillerCol2 = filler[len(filler) / 2:]
    
    # each column of symbols and passwords should be 1/4 of the screen
    fillerWidth = width / 4

    # print the header stuff
    slowWrite(scr, HEADER_TEXT)
    slowWrite(scr, '\nENTER PASSWORD NOW\n\n')
    slowWrite(scr, str(LOGIN_ATTEMPTS) + ' ATTEMPT(S) LEFT: ')
    for i in xrange(LOGIN_ATTEMPTS):
        scr.addch(curses.ACS_BLOCK)
        slowWrite(scr, ' ')
    slowWrite(scr, '\n\n')

    # print the hex and filler
    for i in xrange(fillerHeight):
        slowWrite(scr, "0x%X %s" % (hexCol1[i], fillerCol1[i * fillerWidth: (i + 1) * fillerWidth]), 1)
        if i < fillerHeight - 1:
            scr.addstr('\n')

    for i in xrange(fillerHeight):
        scr.move(HEADER_LINES + i, CONST_CHARS / 2 + fillerWidth)
        slowWrite(scr, '0x%X %s' % (hexCol2[i], fillerCol2[i * fillerWidth: (i + 1) * fillerWidth]), 1)

    scr.refresh()

    return passwords
示例#8
0
def runBoot(scr, hardMode):
    """
    Start the boot portion of the terminal

    hardMode - boolean indicating whether the user has to enter the ENTRY
               constants, or if they are entered automatically
    """
    curses.use_default_colors()
    scr.erase()
    scr.move(0, 0)

    curses.noecho()
    scr.scrollok(True)
    
    slowWrite(scr, MESSAGE_1 + '\n\n')

    if hardMode:
        # use must enter the correct text to proceed
        entry = ''
        while entry.upper() != ENTRY_1.upper():
            slowWrite(scr, '>')
            entry = upperInput(scr)
    else:
        # input is entered for them
        slowWrite(scr, '>')
        curses.napms(INPUT_PAUSE)
        slowWrite(scr, ENTRY_1 + '\n', TYPE_DELAY)

    slowWrite(scr, '\n' + MESSAGE_2 + '\n\n')

    if hardMode:
        entry = ''
        while entry.upper() != ENTRY_2.upper():
            slowWrite(scr, '>')
            entry = upperInput(scr)
        while entry.upper() != ENTRY_3.upper():
            slowWrite(scr, '>')
            entry = upperInput(scr)
    else:
        slowWrite(scr, '>')
        curses.napms(INPUT_PAUSE)
        slowWrite(scr, ENTRY_2 + '\n', TYPE_DELAY)
        slowWrite(scr, '>')
        curses.napms(INPUT_PAUSE)
        slowWrite(scr, ENTRY_3 + '\n', TYPE_DELAY)

    slowWrite(scr, '\n' + MESSAGE_3 + '\n\n')

    if hardMode:
        entry = ''
        while entry.upper() != ENTRY_4.upper():
            slowWrite(scr, '>')
            entry = upperInput(scr)
    else:
        slowWrite(scr, '>')
        curses.napms(INPUT_PAUSE)
        slowWrite(scr, ENTRY_4 + '\n', TYPE_DELAY)
        
    curses.napms(INPUT_PAUSE)
    return True