From c362e6202e2e18d3f99eb13e299c49125783316b Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Wed, 18 Jan 2012 14:34:00 -0500 Subject: [PATCH] A bit more actual user cleaning. --- lib/galaxy/datatypes/registry.py | 1 + lib/galaxy/security/__init__.py | 2 +- lib/galaxy/tools/__init__.py | 28 +++++++++------------------- lib/galaxy/tools/actions/__init__.py | 2 +- tools/data_source/upload.py | 28 ++++++++++++++++------------ universe_wsgi.ini.sample | 1 + 6 files changed, 29 insertions(+), 33 deletions(-) diff --git a/lib/galaxy/datatypes/registry.py b/lib/galaxy/datatypes/registry.py index 2e348e7b764..43c2c1e698e 100644 --- a/lib/galaxy/datatypes/registry.py +++ b/lib/galaxy/datatypes/registry.py @@ -589,3 +589,4 @@ class Registry( object ): os.write( fd, '\n' ) os.write( fd, '\n' ) os.close( fd ) + os.chmod( self.xml_filename, 0644 ) diff --git a/lib/galaxy/security/__init__.py b/lib/galaxy/security/__init__.py index 716964290b5..b2289b1940a 100644 --- a/lib/galaxy/security/__init__.py +++ b/lib/galaxy/security/__init__.py @@ -2,7 +2,7 @@ Galaxy Security """ -import logging, socket, operator, pwd +import logging, socket, operator from datetime import datetime, timedelta from galaxy.util.bunch import Bunch from galaxy.util import listify diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index 7107a260768..2eb6903bd97 100755 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -30,8 +30,6 @@ from galaxy.datatypes import sniff from cgi import FieldStorage from galaxy.util.hash_util import * from galaxy.util import listify -from galaxy.web import security -import socket from galaxy.visualization.tracks.visual_analytics import TracksterConfig @@ -1637,13 +1635,13 @@ class Tool: DatasetFilenameWrapper( converted_dataset, datatypes_registry = self.app.datatypes_registry, tool = Bunch( conversion_name = Bunch( extensions = conv_ext ) ), - name = conversion_name, config_info = self.app.config ) + name = conversion_name ) # Wrap actual input dataset input_values[ input.name ] = \ DatasetFilenameWrapper( input_values[ input.name ], datatypes_registry = self.app.datatypes_registry, tool = self, - name = input.name, config_info = self.app.config ) + name = input.name ) elif isinstance( input, SelectToolParameter ): input_values[ input.name ] = SelectToolParameterWrapper( input, input_values[ input.name ], self.app, other_values = param_dict ) @@ -1681,28 +1679,28 @@ class Tool: param_dict[name] = DatasetFilenameWrapper( data, datatypes_registry = self.app.datatypes_registry, tool = self, - name = name, config_info = self.app.config ) + name = name ) if data: for child in data.children: - param_dict[ "_CHILD___%s___%s" % ( name, child.designation ) ] = DatasetFilenameWrapper( child,config_info = self.app.config ) + param_dict[ "_CHILD___%s___%s" % ( name, child.designation ) ] = DatasetFilenameWrapper( child ) for name, hda in output_datasets.items(): # Write outputs to the working directory (for security purposes) # if desired. if self.app.config.outputs_to_working_directory: try: false_path = [ dp.false_path for dp in output_paths if dp.real_path == hda.file_name ][0] - param_dict[name] = DatasetFilenameWrapper( hda, false_path = false_path, config_info = self.app.config ) + param_dict[name] = DatasetFilenameWrapper( hda, false_path = false_path ) open( false_path, 'w' ).close() except IndexError: log.warning( "Unable to determine alternate path for writing job outputs, outputs will be written to their real paths" ) - param_dict[name] = DatasetFilenameWrapper( hda, config_info = self.app.config ) + param_dict[name] = DatasetFilenameWrapper( hda ) else: - param_dict[name] = DatasetFilenameWrapper( hda, config_info = self.app.config ) + param_dict[name] = DatasetFilenameWrapper( hda ) # Provide access to a path to store additional files # TODO: path munging for cluster/dataset server relocatability param_dict[name].files_path = os.path.abspath(os.path.join( job_working_directory, "dataset_%s_files" % (hda.dataset.id) )) for child in hda.children: - param_dict[ "_CHILD___%s___%s" % ( name, child.designation ) ] = DatasetFilenameWrapper( child, config_info = self.app.config ) + param_dict[ "_CHILD___%s___%s" % ( name, child.designation ) ] = DatasetFilenameWrapper( child ) for out_name, output in self.outputs.iteritems(): if out_name not in param_dict and output.filters: # Assume the reason we lack this output is because a filter @@ -2294,7 +2292,7 @@ class DatasetFilenameWrapper( ToolParameterValueWrapper ): def items( self ): return iter( [ ( k, self.get( k ) ) for k, v in self.metadata.items() ] ) - def __init__( self, dataset, datatypes_registry = None, tool = None, name = None, false_path = None , config_info=None): + def __init__( self, dataset, datatypes_registry = None, tool = None, name = None, false_path = None ): if not dataset: try: # TODO: allow this to work when working with grouping @@ -2306,14 +2304,6 @@ class DatasetFilenameWrapper( ToolParameterValueWrapper ): self.dataset = dataset self.metadata = self.MetadataWrapper( dataset.metadata ) self.false_path = false_path - - # create web_display_url attribute - sec = security.SecurityHelper( id_secret=config_info.id_secret ) - try: - url = 'http://' + socket.getfqdn() + config_info.cookie_path + '/datasets/' + sec.encode_id(dataset.id) + '/display/?preview=True' - self.web_display_url = url - except: - self.web_display_url = None def __str__( self ): if self.false_path is not None: diff --git a/lib/galaxy/tools/actions/__init__.py b/lib/galaxy/tools/actions/__init__.py index 6c542cd7d79..9dd538230bc 100644 --- a/lib/galaxy/tools/actions/__init__.py +++ b/lib/galaxy/tools/actions/__init__.py @@ -149,7 +149,7 @@ class DefaultToolAction( object ): galaxy.tools.DatasetFilenameWrapper( input_values[ input.name ], datatypes_registry = trans.app.datatypes_registry, tool = tool, - name = input.name, config_info = trans.app.config) + name = input.name ) elif isinstance( input, SelectToolParameter ): input_values[ input.name ] = galaxy.tools.SelectToolParameterWrapper( input, input_values[ input.name ], tool.app, other_values = incoming ) else: diff --git a/tools/data_source/upload.py b/tools/data_source/upload.py index 5bbac43ab23..7792d0d5eeb 100644 --- a/tools/data_source/upload.py +++ b/tools/data_source/upload.py @@ -305,19 +305,19 @@ def add_file( dataset, registry, json_file, output_path ): 'Copy files into Galaxy instead of Link to files without copying into Galaxy so grooming can be performed.' file_err( err_msg, dataset, json_file ) return - if link_data_only == 'copy_files' and converted_path is not None: - # Move the converted dataset to its "real" path - shutil.move( converted_path, output_path ) - elif link_data_only == 'copy_files' and in_place: - # Dataset was not converted but should still be removed from original location - shutil.move( dataset.path, output_path ) + if link_data_only == 'copy_files' and dataset.type in ( 'server_dir', 'path_paste' ) and data_type not in [ 'gzip', 'bz2', 'zip' ]: + # Move the dataset to its "real" path + if converted_path is not None: + shutil.copy( converted_path, output_path ) + try: + os.remove( converted_path ) + except: + pass + else: + # This should not happen, but it's here just in case + shutil.copy( dataset.path, output_path ) elif link_data_only == 'copy_files': - shutil.copy( dataset.path, output_path ) - - if link_data_only == 'copy_files' and datatype.dataset_content_needs_grooming( output_path ): - # Groom the dataset content if necessary - datatype.groom_dataset_content( output_path ) - + shutil.move( dataset.path, output_path ) # Write the job info stdout = stdout or 'uploaded %s file' % data_type info = dict( type = 'dataset', @@ -328,6 +328,10 @@ def add_file( dataset, registry, json_file, output_path ): line_count = line_count ) json_file.write( to_json_string( info ) + "\n" ) + if link_data_only == 'copy_files' and datatype.dataset_content_needs_grooming( output_path ): + # Groom the dataset content if necessary + datatype.groom_dataset_content( output_path ) + def add_composite_file( dataset, registry, json_file, output_path, files_path ): if dataset.composite_files: os.mkdir( files_path ) diff --git a/universe_wsgi.ini.sample b/universe_wsgi.ini.sample index 41054ffb718..14fb1dcffe4 100644 --- a/universe_wsgi.ini.sample +++ b/universe_wsgi.ini.sample @@ -640,6 +640,7 @@ use_interactive = True # run with the runner defined with default_cluster_job_runner. [galaxy:tool_runners] + biomart = local:/// encode_db1 = local:/// hbvar = local:///