def save(self): """ Save subject data on filesystem. :ivar str project_path: Project path. :return: Dictionary containing the setup info to save. :rtype: dict """ if not hasattr(self, 'alyx_id'): super().save() return if not self.name: logger.warning("Skipping subject without name") return None else: if not os.path.exists(self.path): os.makedirs(self.path) if self.data: data = self.data else: data = json.scadict( uuid4_id=self.uuid4, software='PyBpod GUI API v'+str(pybpodgui_api.__version__), def_url ='http://pybpod.readthedocs.org', def_text='This file contains information about a subject used on PyBpod GUI.', ) self._save_alyx_member_to_json(data) config_path = os.path.join(self.path, self.name+'.json') with open(config_path, 'w') as fstream: json.dump(data, fstream)
def save(self): """ Save experiment data on filesystem. :ivar dict parent_path: Project path. :return: Dictionary containing the board info to save. If None is returned, it means that ther was a failure. :rtype: dict """ if not self.name: logger.warning("Skipping board without name") return None else: if not os.path.exists(self.path): os.makedirs(self.path) if self.data: data = self.data else: data = json.scadict( uuid4_id=self.uuid4, software='PyBpod GUI API v' + str(pybpodgui_api.__version__), def_url='http://pybpod.readthedocs.org', def_text= 'This file contains the configuration of Bpod board.') data['serial-port'] = self.serial_port data['enabled-bncports'] = self.enabled_bncports data['enabled-wiredports'] = self.enabled_wiredports data['enabled-behaviorports'] = self.enabled_behaviorports data['net-port'] = self.net_port config_path = os.path.join(self.path, self.name + '.json') with open(config_path, 'w') as fstream: json.dump(data, fstream)
def toJSON(self): data = json.scadict( uuid4_id=self.uuid4, software='PyBpod GUI API v' + str(pybpodgui_api.__version__), def_url='http://pybpod.readthedocs.org', def_text= 'This file contains information about a user used on PyBpod GUI.') return json.dumps(data)
def toJSON(self): data = json.scadict( uuid4_id=self.uuid4, software='PyBpod GUI API v' + str(pybpodgui_api.__version__), def_url='http://pybpod.readthedocs.org', def_text= 'This file contains information about a subject used on PyBpod GUI.', ) data['name'] = self.name data['setup'] = str(self.setup.uuid4 if self.setup else None) data['uuid4'] = self.uuid4 return json.dumps(data)
def toJSON(self): if not hasattr(self, 'alyx_id'): return super().toJSON() data = json.scadict( uuid4_id=self.uuid4, software='PyBpod GUI API v'+str(pybpodgui_api.__version__), def_url ='http://pybpod.readthedocs.org', def_text='This file contains information about a subject used on PyBpod GUI.', ) data['name'] = self.name data['uuid4'] = self.uuid4 self._save_alyx_member_to_json(data) return json.dumps(data)
def save(self): """ Save setup data on filesystem. :ivar str project_path: Project path. :ivar dict data: Dictionary where to save the data to. :return: Dictionary containing the task info to save. :rtype: dict """ if (self.path and not os.path.exists(self.path)) or not self.path: self.make_path() if (self.filepath and not os.path.exists(self.filepath)) or not self.filepath: self.filepath = self.make_emptyfile() """ current_path = os.path.dirname(self.filepath) current_filename = os.path.basename(self.filepath) future_path = self.path if current_path!=future_path: shutil.move( current_path, future_path ) current_filepath = os.path.join(future_path, current_filename) future_filepath = os.path.join(future_path, self.name+'.py') shutil.move( current_filepath, future_filepath ) """ if self.data: data = self.data else: data = json.scadict( uuid4_id=self.uuid4, software='PyBpod GUI API v' + str(pybpodgui_api.__version__), def_url='http://pybpod.readthedocs.org', def_text= 'This file contains information about a PyBpod protocol.') data['name'] = self.name data['trigger-softcodes'] = self.trigger_softcodes data['commands'] = [cmd.save() for cmd in self.commands] config_path = os.path.join(self.path, self.name + '.json') with open(config_path, 'w') as fstream: json.dump(data, fstream)
def save(self): if not self.name: logger.warning('Skipping user without a name') return None else: if not os.path.exists(self.path): os.makedirs(self.path) if self.data: data = self.data else: data = json.scadict( uuid4_id=self.uuid4, software='PyBpod GUI API v' + str(pybpodgui_api.__version__), def_url='http://pybpod.readthedocs.org', def_text= 'This file contains information about a user used on PyBpod GUI.' ) config_path = os.path.join(self.path, self.name + '.json') with open(config_path, 'w') as fstream: json.dump(data, fstream)
def save(self): """ Save setup data on filesystem. :ivar str parent_path: Experiment path. :return: Dictionary containing the setup info to save. :rtype: dict """ if not self.name: logger.warning("Skipping setup without name") else: if self.initial_name is not None: initial_path = os.path.join(self.experiment.path, 'setups', self.initial_name) if initial_path != self.path: shutil.move(initial_path, self.path) current_filepath = os.path.join( self.path, self.initial_name + '.json') future_filepath = os.path.join(self.path, self.name + '.json') shutil.move(current_filepath, future_filepath) if not os.path.exists(self.path): os.makedirs(self.path) # save sessions for session in self.sessions: session.save() self.project.remove_non_existing_repositories( os.path.join(self.path, 'sessions'), [session.name for session in self.sessions]) if self.data: data = self.data else: data = json.scadict( uuid4_id=self.uuid4, software='PyBpod GUI API v' + str(pybpodgui_api.__version__), def_url='http://pybpod.readthedocs.org', def_text= 'This file contains information about a PyBpod experiment setup.' ) data['board'] = self.board.name if self.board else None data['task'] = self.task.name if self.task else None data['subjects'] = [subject.name for subject in self.subjects] data['detached'] = self.detached # collect board_task data for key, value in self.board_task.save().items(): data[key] = value if self.board: data.add_external_ref(self.board.uuid4) for subject in self.subjects: data.add_external_ref(subject.uuid4) config_path = os.path.join(self.path, self.name + '.json') with open(config_path, 'w') as fstream: json.dump(data, fstream) self.initial_name = self.name
def save(self, project_path): """ Save project data on file :param str project_path: path to project :return: project data saved on settings file """ if project_path is not None: self.path = project_path logger.debug("saving project path: %s", project_path) logger.debug("current project name: %s", self.name) logger.debug("current project path: %s", self.path) ########### SAVE THE USERS ############ userspath = os.path.join(self.path, 'users') if not os.path.exists(userspath): os.makedirs(userspath) for user in self.users: user.save() self.remove_non_existing_repositories(userspath, [user.name for user in self.users]) ########### SAVE THE TASKS ############ taskspath = os.path.join(self.path, 'tasks') if not os.path.exists(taskspath): os.makedirs(taskspath) for task in self.tasks: task.save() self.remove_non_existing_repositories(taskspath, [task.name for task in self.tasks]) ########### SAVE THE BOARDS ########### boardspath = os.path.join(self.path, 'boards') if not os.path.exists(boardspath): os.makedirs(boardspath) for board in self.boards: board.save() self.remove_non_existing_repositories(boardspath, [board.name for board in self.boards]) ########### SAVE THE SUBJECTS ############### subjectspath = os.path.join(self.path, 'subjects') if not os.path.exists(subjectspath): os.makedirs(subjectspath) for subject in self.subjects: subject.save() self.remove_non_existing_repositories(subjectspath, [subject.name for subject in self.subjects]) ########### SAVE THE EXPERIMENTS ############ experimentspath = os.path.join(self.path, 'experiments') if not os.path.exists(experimentspath): os.makedirs(experimentspath) for experiment in self.experiments: experiment.save() self.remove_non_existing_repositories(experimentspath, [experiment.name for experiment in self.experiments]) ########### SAVE THE PROJECT ############ if self.data: data = self.data else: data = json.scadict( uuid4_id=self.uuid4, software='PyBpod GUI API v'+str(pybpodgui_api.__version__), def_url='http://pybpod.readthedocs.org', def_text='This file contains information about a PyBpod project.' ) data['name'] = self.name name = os.path.basename(self.path) config_path = os.path.join(self.path, name+'.json') with open(config_path, 'w') as fstream: json.dump(data, fstream) self.data_hash = self.__generate_project_hash()