本文整理汇总了Python中tvb.core.entities.file.files_helper.FilesHelper.read_project_metadata方法的典型用法代码示例。如果您正苦于以下问题:Python FilesHelper.read_project_metadata方法的具体用法?Python FilesHelper.read_project_metadata怎么用?Python FilesHelper.read_project_metadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tvb.core.entities.file.files_helper.FilesHelper
的用法示例。
在下文中一共展示了FilesHelper.read_project_metadata方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProjectUpdateManager
# 需要导入模块: from tvb.core.entities.file.files_helper import FilesHelper [as 别名]
# 或者: from tvb.core.entities.file.files_helper.FilesHelper import read_project_metadata [as 别名]
class ProjectUpdateManager(UpdateManager):
"""
This goes through all the scripts that are newer than the version number
written in the current project metadata xml, and executes them on the project folder.
"""
def __init__(self, project_path):
self.project_path = project_path
self.files_helper = FilesHelper()
# This assumes that old project metadata file can be parsed by current version.
self.project_meta = self.files_helper.read_project_metadata(project_path)
from_version = int(self.project_meta.get('version', 0))
super(ProjectUpdateManager, self).__init__(project_update_scripts, from_version,
TvbProfile.current.version.PROJECT_VERSION)
def run_all_updates(self):
"""
Upgrade the project to the latest structure
Go through all update scripts, from project version up to the current_version in the code
"""
super(ProjectUpdateManager, self).run_all_updates(project_path=self.project_path)
# update project version in metadata
self.project_meta['version'] = self.current_version
self.files_helper.write_project_metadata_from_dict(self.project_path, self.project_meta)
示例2: ImportService
# 需要导入模块: from tvb.core.entities.file.files_helper import FilesHelper [as 别名]
# 或者: from tvb.core.entities.file.files_helper.FilesHelper import read_project_metadata [as 别名]
#.........这里部分代码省略.........
type_instance.set_operation_id(op_id)
# Now move storage file into correct folder if necessary
current_file = os.path.join(storage_folder, file_name)
new_file = type_instance.get_storage_file_path()
if new_file != current_file and move:
shutil.move(current_file, new_file)
return type_instance
def store_datatype(self, datatype):
"""This method stores data type into DB"""
try:
self.logger.debug("Store datatype: %s with Gid: %s" % (datatype.__class__.__name__, datatype.gid))
return dao.store_entity(datatype)
except MissingDataSetException:
self.logger.error("Datatype %s has missing data and could not be imported properly." % (datatype,))
os.remove(datatype.get_storage_file_path())
except IntegrityError as excep:
self.logger.exception(excep)
error_msg = "Could not import data with gid: %s. There is already a one with " \
"the same name or gid." % datatype.gid
# Delete file if can't be imported
os.remove(datatype.get_storage_file_path())
raise ProjectImportException(error_msg)
def __populate_project(self, project_path):
"""
Create and store a Project entity.
"""
self.logger.debug("Creating project from path: %s" % project_path)
project_dict = self.files_helper.read_project_metadata(project_path)
project_entity = manager_of_class(model.Project).new_instance()
project_entity = project_entity.from_dict(project_dict, self.user_id)
try:
self.logger.debug("Storing imported project")
return dao.store_entity(project_entity)
except IntegrityError as excep:
self.logger.exception(excep)
error_msg = ("Could not import project: %s with gid: %s. There is already a "
"project with the same name or gid.") % (project_entity.name, project_entity.gid)
raise ProjectImportException(error_msg)
def __build_operation_from_file(self, project, operation_file):
"""
Create Operation entity from metadata file.
"""
operation_dict = XMLReader(operation_file).read_metadata()
operation_entity = manager_of_class(model.Operation).new_instance()
return operation_entity.from_dict(operation_dict, dao, self.user_id, project.gid)
@staticmethod
def __import_operation(operation_entity):
"""
Store a Operation entity.
"""
operation_entity = dao.store_entity(operation_entity)
operation_group_id = operation_entity.fk_operation_group
datatype_group = None