2015-05-26 21:37:25 +00:00
|
|
|
import curses
|
2015-05-27 01:11:31 +00:00
|
|
|
from fallout_functions import slowWrite
|
2015-06-14 21:05:56 +00:00
|
|
|
from fallout_functions import INPUT_PAUSE
|
|
|
|
from fallout_functions import TYPE_DELAY
|
|
|
|
from fallout_functions import upperInput
|
|
|
|
from fallout_functions import HIDDEN_MASK
|
2024-04-28 15:02:47 +00:00
|
|
|
|
2015-05-27 01:11:31 +00:00
|
|
|
################## text strings ######################
|
|
|
|
|
2024-04-28 15:02:47 +00:00
|
|
|
HEADER_TEXT = "WELCOME TO ROBCO INDUSTRIES (TM) TERMLINK"
|
2015-05-26 21:37:25 +00:00
|
|
|
|
2024-04-28 15:02:47 +00:00
|
|
|
PASSWORD_PROMPT = "ENTER PASSWORD NOW"
|
2015-05-26 21:37:25 +00:00
|
|
|
|
2024-04-28 15:02:47 +00:00
|
|
|
PASSWORD_ERROR = "INCORRECT PASSWORD, PLEASE TRY AGAIN"
|
2015-05-26 21:37:25 +00:00
|
|
|
|
2015-06-14 21:05:56 +00:00
|
|
|
################## global "constants" ################
|
2015-05-26 21:37:25 +00:00
|
|
|
|
2024-04-28 15:02:47 +00:00
|
|
|
ENTRY = "LOGON "
|
2015-05-26 21:37:25 +00:00
|
|
|
|
|
|
|
################## functions #########################
|
|
|
|
|
2024-04-28 15:02:47 +00:00
|
|
|
|
2015-06-14 21:05:56 +00:00
|
|
|
def runLogin(scr, hardMode, username, password):
|
2015-05-26 21:37:25 +00:00
|
|
|
"""
|
2015-06-14 21:05:56 +00:00
|
|
|
Start the login process
|
2015-05-26 21:37:25 +00:00
|
|
|
|
2024-04-28 15:02:47 +00:00
|
|
|
hardMode - boolean indicating whether the user has to enter the username
|
2015-06-14 21:05:56 +00:00
|
|
|
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
|
2015-05-26 21:37:25 +00:00
|
|
|
"""
|
2015-05-27 01:11:31 +00:00
|
|
|
curses.use_default_colors()
|
|
|
|
scr.erase()
|
|
|
|
scr.move(0, 0)
|
2015-05-26 21:37:25 +00:00
|
|
|
|
2015-06-14 21:05:56 +00:00
|
|
|
curses.noecho()
|
|
|
|
scr.scrollok(True)
|
|
|
|
|
2024-04-28 15:02:47 +00:00
|
|
|
slowWrite(scr, HEADER_TEXT + "\n\n")
|
2015-06-14 21:05:56 +00:00
|
|
|
|
|
|
|
if hardMode:
|
|
|
|
# use must enter the correct text to proceed
|
2024-04-28 15:02:47 +00:00
|
|
|
entry = ""
|
2015-06-14 21:05:56 +00:00
|
|
|
while entry.upper() != ENTRY.upper() + username.upper():
|
2024-04-28 15:02:47 +00:00
|
|
|
slowWrite(scr, "> ")
|
2015-06-14 21:05:56 +00:00
|
|
|
entry = upperInput(scr)
|
|
|
|
else:
|
|
|
|
# input is entered for them
|
2024-04-28 15:02:47 +00:00
|
|
|
slowWrite(scr, "> ")
|
2015-06-14 21:05:56 +00:00
|
|
|
curses.napms(INPUT_PAUSE)
|
2024-04-28 15:02:47 +00:00
|
|
|
slowWrite(scr, ENTRY + username.upper() + "\n", TYPE_DELAY, True)
|
2015-06-14 21:05:56 +00:00
|
|
|
|
2024-04-28 15:02:47 +00:00
|
|
|
slowWrite(scr, "\n" + PASSWORD_PROMPT + "\n\n")
|
2015-06-14 21:05:56 +00:00
|
|
|
|
|
|
|
if hardMode:
|
|
|
|
# use must enter the correct text to proceed
|
2024-04-28 15:02:47 +00:00
|
|
|
entry = ""
|
2015-06-14 21:05:56 +00:00
|
|
|
while entry.upper() != password.upper():
|
|
|
|
if entry:
|
2024-04-28 15:02:47 +00:00
|
|
|
slowWrite(scr, PASSWORD_ERROR + "\n\n")
|
|
|
|
|
|
|
|
slowWrite(scr, "> ")
|
2015-06-14 21:05:56 +00:00
|
|
|
entry = upperInput(scr, True)
|
|
|
|
else:
|
|
|
|
# input is entered for them
|
2024-04-28 15:02:47 +00:00
|
|
|
slowWrite(scr, "> ")
|
2015-06-14 21:05:56 +00:00
|
|
|
curses.napms(INPUT_PAUSE)
|
|
|
|
password_stars = HIDDEN_MASK * len(password)
|
2024-04-28 15:02:47 +00:00
|
|
|
slowWrite(scr, password_stars + "\n", TYPE_DELAY, True)
|
2015-05-26 21:37:25 +00:00
|
|
|
|
2015-06-14 21:05:56 +00:00
|
|
|
curses.napms(500)
|
|
|
|
|
|
|
|
|
|
|
|
def beginLogin(hardMode, username, password):
|
2015-05-26 21:37:25 +00:00
|
|
|
"""
|
|
|
|
Initialize curses and start the login process
|
2015-06-14 21:05:56 +00:00
|
|
|
|
|
|
|
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
|
2015-05-26 21:37:25 +00:00
|
|
|
"""
|
2015-06-14 21:05:56 +00:00
|
|
|
res = curses.wrapper(runLogin, hardMode, username, password)
|
|
|
|
return res
|