From be48e66aedca41955a6df9c352941129e7c389cd Mon Sep 17 00:00:00 2001 From: Bernard Blackham Date: Sun, 27 Jun 2004 18:47:58 +0000 Subject: [PATCH] More fixes --- sql-edition/servers/VendServer.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/sql-edition/servers/VendServer.py b/sql-edition/servers/VendServer.py index b173d3c..68c09b3 100755 --- a/sql-edition/servers/VendServer.py +++ b/sql-edition/servers/VendServer.py @@ -56,8 +56,13 @@ def scroll_options(username, mk, welcome = False): else: msg = [] choices = ' '*10+'CHOICES: ' - coke_machine = file('/home/other/coke/coke_contents') - cokes = coke_machine.readlines() + try: + coke_machine = file('/home/other/coke/coke_contents') + cokes = coke_machine.readlines() + coke_machine.close() + except: + cokes = [] + pass for c in cokes: c = c.strip() (slot_num, price, slot_name) = c.split(' ', 2) @@ -65,7 +70,8 @@ def scroll_options(username, mk, welcome = False): choices += '%s8-%s (%sc) '%(slot_num, slot_name, price) choices += '55-DOOR ' choices += 'OR A SNACK. ' - choices += '99 TO READ AGAIN.' + choices += '99 TO READ AGAIN. ' + choices += 'CHOICE? ' msg.append((choices, False, None)) mk.set_messages(msg) @@ -142,7 +148,7 @@ class MessageKeeper: if len(self.scrolling_message[0][0]) > 10: (m, r, t) = self.scrolling_message[0] a = [] - exp = HorizScroll(m).expand(padding = 10) + exp = HorizScroll(m).expand(padding = 0, wraparound = False) if t == None: t = 0.1 else: @@ -203,7 +209,7 @@ if __name__ == '__main__': if logout_timeout != None: time_left = logout_timeout - time() - if time_left < 10 and (last_timeout_refresh is None or last_timeout_refresh > time_left): + if time_left < 5 and (last_timeout_refresh is None or last_timeout_refresh > time_left): mk.set_message('LOGOUT: '+str(int(time_left))) last_timeout_refresh = int(time_left) @@ -217,7 +223,8 @@ if __name__ == '__main__': if logout_timeout and not mk.done(): logout_timeout = None if len(cur_pin) == PIN_LENGTH and mk.done() and logout_timeout == None: # start autologout - logout_timeout = time() + 10 + logout_timeout = time() + 15 + cur_selection = '' mk.update_display() @@ -302,9 +309,11 @@ if __name__ == '__main__': elif len(cur_selection) == 1: if key == 11: cur_selection = '' + logout_timeout = None scroll_options(username, mk) continue else: + logout_timeout = 10 cur_selection += chr(key + ord('0')) #make_selection(cur_selection) # XXX this should move somewhere else: -- 2.20.1