mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-21 05:45:37 +08:00
Merge pull request #5552 from davebx/18.01
[18.01] Close tempfile handles.
This commit is contained in:
@@ -27,28 +27,24 @@ class ValidationContext(object):
|
||||
self.config = Bunch()
|
||||
self.config.tool_data_path = tool_data_path
|
||||
self.config.shed_tool_data_path = shed_tool_data_path
|
||||
_, self.config.tool_data_table_config = tempfile.mkstemp()
|
||||
_, self.config.shed_tool_data_table_config = tempfile.mkstemp()
|
||||
self.temporary_path = tempfile.mkdtemp(prefix='tool_validation_')
|
||||
self.config.tool_data_table_config = os.path.join(self.temporary_path, 'tool_data_table_conf.xml')
|
||||
self.config.shed_tool_data_table_config = os.path.join(self.temporary_path, 'shed_tool_data_table_conf.xml')
|
||||
self.tool_data_tables = tool_data_tables
|
||||
self.datatypes_registry = registry or Registry()
|
||||
self.hgweb_config_manager = hgweb_config_manager
|
||||
_, self.config.len_file_path = tempfile.mkstemp()
|
||||
_, self.config.builds_file_path = tempfile.mkstemp()
|
||||
self.config.len_file_path = os.path.join(self.temporary_path, 'chromlen.txt')
|
||||
# If the builds file path is set to None, tools/__init__.py will load the default.
|
||||
# Otherwise it will attempt to load a nonexistent file and log an error. This does
|
||||
# not appear to be an issue with the len_file_path config option.
|
||||
self.config.builds_file_path = None
|
||||
self.genome_builds = GenomeBuilds(self)
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
cleanup_paths = {self.config.builds_file_path,
|
||||
self.config.len_file_path,
|
||||
self.config.tool_data_table_config,
|
||||
self.config.shed_tool_data_table_config}
|
||||
for path in cleanup_paths:
|
||||
try:
|
||||
os.remove(path)
|
||||
except Exception:
|
||||
pass
|
||||
shutil.rmtree(self.temporary_path)
|
||||
|
||||
@staticmethod
|
||||
@contextmanager
|
||||
|
||||
Reference in New Issue
Block a user