Changeset 641 in tmcsimulator for branches/LCSv2/controllers/default.py
- Timestamp:
- 03/13/2021 05:17:45 PM (5 years ago)
- File:
-
- 1 edited
-
branches/LCSv2/controllers/default.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/LCSv2/controllers/default.py
r636 r641 1 1 # added comments for testing 2 2 # Constants 3 kLogfile = " samplelogfile.txt"3 kLogfile = "LCSlogfile.txt" 4 4 kSimtimefile = "sim_elapsedtime.json" #"../webapps/dynamicdata/sim_elapsed_time.json" 5 5 hwys = ['','1','5', '22', '55', '57', '73', '74', '91', '133', '142', '241', '261', '405', '605'] … … 7 7 # Names to appear in the username dropdown box 8 8 users = [] 9 users.append('') 9 10 # Show the login page 10 11 def index(): 11 12 userfile = open('student_names.txt','r') 12 users = [line.strip() for line in userfile.readlines()] 13 users.insert(0,'') 13 # read the file into a buffer 14 buffer = [line.strip() for line in userfile.readlines()] 15 # Append each name in the buffer to the users list, skipping blank lines 16 for item in buffer: 17 if len(item) > 0: 18 users.append(item) 19 # build the form 14 20 form = FORM(LABEL('User:',_for='username', _class="label username-label"), 15 21 #INPUT(_name='username', _size='15', _style="font-size: 18px;"), BR(), … … 18 24 if form.process().accepted: 19 25 # Put the username entry into the session variable 20 session.username = form.vars.username26 session.username = reverseNameFields(form.vars.username) 21 27 redirect(URL('home')) 22 28 return dict(form=form) … … 376 382 return "NO" 377 383 384 # Swap the fields in a name, changing lastname first to firstname first. 385 def reverseNameFields(formattedname): 386 # Divide the name into last and first names 387 x = formattedname.split(',') 388 # If there isn't a comma, return the entire name 389 if len(x) == 1: 390 return x[0].strip() 391 else: # return the swapped fields 392 return x[1].strip() + ' ' + x[0] 393 378 394 # Convert the lanes closed checkboxes into a human readable string 379 395 # E.g. #1 #3 of 4
Note: See TracChangeset
for help on using the changeset viewer.
