MCPcopy Create free account
hub / github.com/brain-workshop/brainworkshop / load_last_user

Function load_last_user

brainworkshop.py:695–719  ·  view source on GitHub ↗
(lastuserpath)

Source from the content-addressed store, hash-verified

693 return pyglet.event.EVENT_HANDLED
694
695def 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
721def save_last_user(lastuserpath):
722 try:

Callers 1

brainworkshop.pyFile · 0.85

Calls 3

get_data_dirFunction · 0.85
debug_msgFunction · 0.85
closeMethod · 0.45

Tested by

no test coverage detected