Fixed a minor bug: 'message' variable changed prompt-message whenever exceptions was caught, it manifested in the subsequent iterations.

This commit is contained in:
Kon 2013-04-13 14:58:13 -04:00
parent f46b1f71ea
commit ce28c455aa

View file

@ -197,13 +197,14 @@ def build_repository(project_directory):
# Handle the expiration time. The expiration date determines when
# the top-level roles expire.
message = '\nWhen would you like your certificates to expire? (mm/dd/yyyy): '
prompt_message = \
'\nWhen would you like your certificates to expire? (mm/dd/yyyy): '
timeout = None
for attempt in range(MAX_INPUT_ATTEMPTS):
# Get the difference between the user's entered expiration date and today's
# date. Convert and store the difference to total days till expiration.
try:
input_date = _prompt(message)
input_date = _prompt(prompt_message)
expiration_date = datetime.datetime.strptime(input_date, '%m/%d/%Y')
time_difference = expiration_date - datetime.datetime.now()
timeout = time_difference.days
@ -299,11 +300,12 @@ def build_repository(project_directory):
# Ensure the user inputs a valid threshold value.
role_threshold = None
for attempt in range(MAX_INPUT_ATTEMPTS):
message = '\nEnter the desired threshold for the role '+repr(role)+': '
prompt_message = \
'\nEnter the desired threshold for the role '+repr(role)+': '
# Check for non-integers and values less than one.
try:
role_threshold = _prompt(message, int)
role_threshold = _prompt(prompt_message, int)
if not tuf.formats.THRESHOLD_SCHEMA.matches(role_threshold):
raise ValueError
break