Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pybpodgui_api/models/user/user_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UserIO(UserBase):
def __init__(self, _project):
super(UserIO, self).__init__(_project)

self.data = None # DOn't know if we actualy need this
self.data = None # Don't know if we actually need this

def save(self):
if not self.name:
Expand Down Expand Up @@ -49,13 +49,16 @@ def toJSON(self):

def load(self, path):
self.name = os.path.basename(path)
config_file = os.path.join(self.path, self.name + '.json')
if not os.path.exists(config_file) or os.path.getsize(config_file) == 0:
return

try:
with open(os.path.join(self.path, self.name + '.json'), 'r') as stream:
with open(config_file, 'r') as stream:
self.data = data = json.load(stream)
self.uuid4 = data.uuid4 if data.uuid4 else self.uuid4
except:
raise Exception('There was an error loading the configuration file for the subject [{0}]')
raise Exception(f'There was an error loading the configuration file for the user [{self.name}]')

def collect_data(self, data):
data.update({'name': self.name})
Expand Down