(lastuserpath)
| 693 | return pyglet.event.EVENT_HANDLED |
| 694 | |
| 695 | def load_last_user(lastuserpath): |
| 696 | path = os.path.join(get_data_dir(), lastuserpath) |
| 697 | if os.path.isfile(path): |
| 698 | debug_msg("Trying to load '%s'" % (path)) |
| 699 | try: |
| 700 | f = open(path, 'rb') |
| 701 | p = pickle.Unpickler(f) |
| 702 | options = p.load() |
| 703 | del p |
| 704 | f.close() |
| 705 | except Exception as e: |
| 706 | print("%s\nDue to error, continuing as user 'default'" % e) |
| 707 | # Delete the pickle file, since it wasn't able to be loaded. |
| 708 | os.remove(path) |
| 709 | return |
| 710 | if options['USER'] == '': |
| 711 | print("Last loaded user is an empty string! Setting it to default instead") |
| 712 | options['USER'] = "default" |
| 713 | if not options['USER'].lower() == 'default': |
| 714 | global USER |
| 715 | global STATS_BINARY |
| 716 | global CONFIGFILE |
| 717 | USER = options['USER'] |
| 718 | CONFIGFILE = USER + '-config.ini' |
| 719 | STATS_BINARY = USER + '-logfile.dat' |
| 720 | |
| 721 | def save_last_user(lastuserpath): |
| 722 | try: |
no test coverage detected