diff --git a/python/eeg2bids.py b/python/eeg2bids.py index f6a43c0..75ea34f 100644 --- a/python/eeg2bids.py +++ b/python/eeg2bids.py @@ -21,6 +21,7 @@ # Create socket listener. sio = socketio.Server(async_mode='eventlet', cors_allowed_origins=[]) app = socketio.WSGIApp(sio) +loris_api = LorisAPI() # Create Loris API handler. @@ -71,27 +72,22 @@ def set_loris_credentials(sid, data): sio.emit('loris_projects', loris_api.get_projects()) -@sio.event def get_loris_sites(sid): - print('get_loris_sites has ran!') sio.emit('loris_sites', loris_api.get_sites()) - + @sio.event def get_loris_projects(sid): - print('get_loris_projects has ran!') sio.emit('loris_projects', loris_api.get_projects()) @sio.event def get_loris_subprojects(sid, project): - print('get_loris_subprojects has ran!') sio.emit('loris_subprojects', loris_api.get_subprojects(project)) @sio.event def get_loris_visits(sid, project): - print('get_loris_visits has ran!') sio.emit('loris_visits', loris_api.get_visits(project)) @@ -117,18 +113,18 @@ def ieeg_get_header(sid, data): def get_metadata(sid, data): # data = { file_path: 'path to metadata file' } print('metadata file:', data) - + if not data['file_path']: print('No file path found.') response = { 'error': 'No file path found.', } - else: + else : try: with open(data['file_path']) as fd: reader = csv.DictReader(fd, delimiter="\t", quotechar='"') response = { - 'metadata': {rows['Field']: rows['Value'] for rows in reader} + 'metadata': {rows['Field']:rows['Value'] for rows in reader} } except IOError: print("Could not read the metadata file.") diff --git a/python/libs/loris_api.py b/python/libs/loris_api.py index da4b065..f4b9180 100644 --- a/python/libs/loris_api.py +++ b/python/libs/loris_api.py @@ -8,30 +8,19 @@ class LorisAPI: username = '' password = '' - # url = 'https://inhance-dev.loris.ca/api/v0.0.3/' - # username = 'admin' - # password = 'LORISitb2021!' token = '' def __init__(self): # self.login() - # self.get_projects() - # self.get_sites() - # self.save_instrument() - # self.get_project('Pumpernickel') - # self.create_candidate() - # visit = self.get_visit(317604, 'Visit 01', 'Data Coordinating Center', 'Stale', 'Pumpernickel') - # print(visit) - # self.start_next_stage(317604, 'Visit 01', 'Data Coordinating Center', 'Stale', 'Pumpernickel', "2021-03-06") def login(self): resp = json.loads(requests.post( - url=self.url + 'login', - json={ - 'username': self.username, + url = self.url + 'login', + json = { + 'username': self.username, 'password': self.password }, - verify=False + verify = False ).content.decode('ascii')) if resp.get('error'): diff --git a/src/jsx/Configuration.js b/src/jsx/Configuration.js index af5057e..a4b3a5f 100644 --- a/src/jsx/Configuration.js +++ b/src/jsx/Configuration.js @@ -122,6 +122,10 @@ const Configuration = (props) => { Object.keys(state).map((key) => appContext.setTask(key, state[key].get)); }, []); + useEffect(() => { + Object.keys(state).map((key) => appContext.setTask(key, state[key].get)); + }, []); + /** * Similar to componentDidMount and componentDidUpdate. */ @@ -683,7 +687,7 @@ const Configuration = (props) => { /> } - {state.participantEntryMode.get === 'loris' && + {state.participantEntryMode.get == 'loris' && <>