mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-11-01 11:14:34 +08:00
Use NamedTemporaryFile opened in text mode
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
import logging
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
from six import string_types, text_type
|
||||
from six.moves import shlex_quote
|
||||
|
||||
from galaxy import exceptions
|
||||
from galaxy.util import (
|
||||
odict,
|
||||
smart_str,
|
||||
)
|
||||
from galaxy.util import odict
|
||||
from galaxy.util.none_like import NoneDataset
|
||||
from galaxy.util.object_wrapper import wrap_with_safe_string
|
||||
|
||||
@@ -321,10 +317,10 @@ class HasDatasets(object):
|
||||
return DatasetFilenameWrapper(dataset, **wrapper_kwds)
|
||||
|
||||
def paths_as_file(self, sep="\n"):
|
||||
handle, filepath = tempfile.mkstemp(prefix="gx_file_list", dir=self.job_working_directory)
|
||||
contents = sep.join(map(str, self))
|
||||
os.write(handle, smart_str(contents))
|
||||
os.close(handle)
|
||||
with tempfile.NamedTemporaryFile(mode='w+', prefix="gx_file_list", dir=self.job_working_directory, delete=False) as fh:
|
||||
fh.write(contents)
|
||||
filepath = fh.name
|
||||
return filepath
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user