mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 00:12:08 +08:00
Revert 2715.
This commit is contained in:
@@ -31,8 +31,6 @@ class Configuration( object ):
|
||||
# Where dataset files are stored
|
||||
self.file_path = resolve_path( kwargs.get( "file_path", "database/files" ), self.root )
|
||||
self.new_file_path = resolve_path( kwargs.get( "new_file_path", "database/tmp" ), self.root )
|
||||
# Directory to be used when creating temporary files ( generally from tools )
|
||||
self.tmp_file_path = resolve_path( kwargs.get( "tmp_file_path", "/tmp" ), self.root )
|
||||
self.tool_path = resolve_path( kwargs.get( "tool_path", "tools" ), self.root )
|
||||
self.tool_data_path = resolve_path( kwargs.get( "tool_data_path", "tool-data" ), os.getcwd() )
|
||||
self.test_conf = resolve_path( kwargs.get( "test_conf", "" ), self.root )
|
||||
|
||||
@@ -223,10 +223,10 @@ class Data( object ):
|
||||
|
||||
class Text( Data ):
|
||||
|
||||
def write_from_stream( self, dataset, stream, directory=None ):
|
||||
def write_from_stream(self, dataset, stream):
|
||||
"""Writes data from a stream"""
|
||||
# write it twice for now
|
||||
fd, temp_name = tempfile.mkstemp( dir=directory )
|
||||
fd, temp_name = tempfile.mkstemp()
|
||||
while 1:
|
||||
chunk = stream.read(1048576)
|
||||
if not chunk:
|
||||
@@ -241,9 +241,9 @@ class Text( Data ):
|
||||
fp.write(line)
|
||||
fp.close()
|
||||
|
||||
def set_raw_data( self, dataset, data, directory=None ):
|
||||
def set_raw_data(self, dataset, data):
|
||||
"""Saves the data on the disc"""
|
||||
fd, temp_name = tempfile.mkstemp( dir=directory )
|
||||
fd, temp_name = tempfile.mkstemp()
|
||||
os.write(fd, data)
|
||||
os.close(fd)
|
||||
|
||||
|
||||
@@ -12,11 +12,11 @@ def get_test_fname(fname):
|
||||
full_path = os.path.join(path, 'test', fname)
|
||||
return full_path
|
||||
|
||||
def stream_to_file( stream, directory=None ):
|
||||
def stream_to_file(stream):
|
||||
"""
|
||||
Writes a stream to a temporary file, returns the temporary file's name
|
||||
"""
|
||||
fd, temp_name = tempfile.mkstemp( dir=directory )
|
||||
fd, temp_name = tempfile.mkstemp()
|
||||
while 1:
|
||||
chunk = stream.read(1048576)
|
||||
if not chunk:
|
||||
@@ -25,7 +25,7 @@ def stream_to_file( stream, directory=None ):
|
||||
os.close(fd)
|
||||
return temp_name
|
||||
|
||||
def convert_newlines( fname, directory=None ):
|
||||
def convert_newlines( fname ):
|
||||
"""
|
||||
Converts in place a file from universal line endings
|
||||
to Posix line endings.
|
||||
@@ -37,7 +37,7 @@ def convert_newlines( fname, directory=None ):
|
||||
>>> file(fname).read()
|
||||
'1 2\\n3 4\\n'
|
||||
"""
|
||||
fd, temp_name = tempfile.mkstemp( dir=directory )
|
||||
fd, temp_name = tempfile.mkstemp()
|
||||
fp = os.fdopen( fd, "wt" )
|
||||
for i, line in enumerate( file( fname, "U" ) ):
|
||||
fp.write( "%s\n" % line.rstrip( "\r\n" ) )
|
||||
@@ -46,7 +46,7 @@ def convert_newlines( fname, directory=None ):
|
||||
# Return number of lines in file.
|
||||
return i + 1
|
||||
|
||||
def sep2tabs( fname, patt="\\s+", directory=None ):
|
||||
def sep2tabs(fname, patt="\\s+"):
|
||||
"""
|
||||
Transforms in place a 'sep' separated file to a tab separated one
|
||||
|
||||
@@ -58,7 +58,7 @@ def sep2tabs( fname, patt="\\s+", directory=None ):
|
||||
'1\\t2\\n3\\t4\\n'
|
||||
"""
|
||||
regexp = re.compile( patt )
|
||||
fd, temp_name = tempfile.mkstemp( dir=directory )
|
||||
fd, temp_name = tempfile.mkstemp()
|
||||
fp = os.fdopen( fd, "wt" )
|
||||
for i, line in enumerate( file( fname ) ):
|
||||
line = line.rstrip( '\r\n' )
|
||||
@@ -69,7 +69,7 @@ def sep2tabs( fname, patt="\\s+", directory=None ):
|
||||
# Return number of lines in file.
|
||||
return i + 1
|
||||
|
||||
def convert_newlines_sep2tabs( fname, patt="\\s+", directory=None ):
|
||||
def convert_newlines_sep2tabs( fname, patt="\\s+" ):
|
||||
"""
|
||||
Combines above methods: convert_newlines() and sep2tabs()
|
||||
so that files do not need to be read twice
|
||||
@@ -82,7 +82,7 @@ def convert_newlines_sep2tabs( fname, patt="\\s+", directory=None ):
|
||||
'1\\t2\\n3\\t4\\n'
|
||||
"""
|
||||
regexp = re.compile( patt )
|
||||
fd, temp_name = tempfile.mkstemp( dir=directory )
|
||||
fd, temp_name = tempfile.mkstemp()
|
||||
fp = os.fdopen( fd, "wt" )
|
||||
for i, line in enumerate( file( fname, "U" ) ):
|
||||
line = line.rstrip( '\r\n' )
|
||||
|
||||
@@ -174,7 +174,6 @@ class Dataset( object ):
|
||||
EMPTY = 'empty',
|
||||
ERROR = 'error',
|
||||
DELETED = 'deleted')
|
||||
# The following is used for functional tests
|
||||
file_path = "/tmp/"
|
||||
engine = None
|
||||
def __init__( self, id=None, hid=None, name=None, info=None, blurb=None, peek=None, extension=None,
|
||||
|
||||
@@ -985,8 +985,6 @@ class Tool:
|
||||
param_dict['__new_file_path__'] = os.path.abspath(self.app.config.new_file_path)
|
||||
# The following points to location (xxx.loc) files which are pointers to locally cached data
|
||||
param_dict['GALAXY_DATA_INDEX_DIR'] = self.app.config.tool_data_path
|
||||
# Directory to be used when creating temporary files ( generally from tools )
|
||||
param_dict['GALAXY_TMP_FILE_DIR'] = self.app.config.tmp_file_path
|
||||
# Return the dictionary of parameters
|
||||
return param_dict
|
||||
|
||||
|
||||
@@ -79,8 +79,7 @@ class UploadToolAction( object ):
|
||||
|
||||
def add_file( self, trans, file_obj, file_name, file_type, dbkey, info=None, space_to_tab=False ):
|
||||
data_type = None
|
||||
tmp_file_path = trans.app.config.tmp_file_path
|
||||
temp_name = sniff.stream_to_file( file_obj, directory=tmp_file_path )
|
||||
temp_name = sniff.stream_to_file( file_obj )
|
||||
|
||||
# See if we have an empty file
|
||||
if not os.path.getsize( temp_name ) > 0:
|
||||
@@ -93,7 +92,7 @@ class UploadToolAction( object ):
|
||||
elif is_gzipped and is_valid:
|
||||
#We need to decompress the temp_name file
|
||||
CHUNK_SIZE = 2**20 # 1Mb
|
||||
fd, uncompressed = tempfile.mkstemp( dir=tmp_file_path )
|
||||
fd, uncompressed = tempfile.mkstemp()
|
||||
gzipped_file = gzip.GzipFile( temp_name )
|
||||
while 1:
|
||||
try:
|
||||
@@ -147,7 +146,7 @@ class UploadToolAction( object ):
|
||||
|
||||
if data_type != 'binary' and data_type != 'zip':
|
||||
if space_to_tab:
|
||||
self.line_count = sniff.convert_newlines_sep2tabs( temp_name, directory=tmp_file_path )
|
||||
self.line_count = sniff.convert_newlines_sep2tabs( temp_name )
|
||||
else:
|
||||
self.line_count = sniff.convert_newlines( temp_name )
|
||||
if file_type == 'auto':
|
||||
|
||||
+508
-508
File diff suppressed because it is too large
Load Diff
@@ -143,7 +143,7 @@ def maf_index_by_uid( maf_uid, index_location_file ):
|
||||
return None
|
||||
|
||||
#builds and returns (index, index_filename) for specified maf_file
|
||||
def build_maf_index( maf_file, species=None, directory=None ):
|
||||
def build_maf_index( maf_file, species = None ):
|
||||
indexes = bx.interval_index_file.Indexes()
|
||||
try:
|
||||
maf_reader = bx.align.maf.Reader( open( maf_file ) )
|
||||
@@ -156,7 +156,7 @@ def build_maf_index( maf_file, species=None, directory=None ):
|
||||
if species is not None and c.src.split( "." )[0] not in species:
|
||||
continue
|
||||
indexes.add( c.src, c.forward_strand_start, c.forward_strand_end, pos )
|
||||
fd, index_filename = tempfile.mkstemp( dir=directory )
|
||||
fd, index_filename = tempfile.mkstemp()
|
||||
out = os.fdopen( fd, 'w' )
|
||||
indexes.write( out )
|
||||
out.close()
|
||||
|
||||
Reference in New Issue
Block a user