4 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/0255f2f29a2b/
Changeset: 0255f2f29a2b
Branch: next-stable
User: Dave Bouvier
Date: 2013-10-25 20:39:44
Summary: Check for matching in-memory sniffer before appending. Remove sniffer when deactivating or uninstalling a repository. Additional checks for keys existing before deleting them.
Affected #: 1 file
diff -r 8109823f43c30a7efa744471b657efbc9624b218 -r 0255f2f29a2ba9fd047c89be919453ea90ab731f lib/galaxy/datatypes/registry.py
--- a/lib/galaxy/datatypes/registry.py
+++ b/lib/galaxy/datatypes/registry.py
@@ -217,7 +217,8 @@
if sniffers:
for elem in sniffers.findall( 'sniffer' ):
# Keep an in-memory list of sniffer elems to enable persistence.
- self.sniffer_elems.append( elem )
+ if elem not in self.sniffer_elems:
+ self.sniffer_elems.append( elem )
dtype = elem.get( 'type', None )
if dtype:
try:
@@ -239,6 +240,8 @@
module = getattr( module, comp )
aclass = getattr( module, datatype_class_name )()
if deactivate:
+ if elem in self.sniffer_elems:
+ self.sniffer_elems.remove( elem )
for sniffer_class in self.sniff_order:
if sniffer_class.__class__ == aclass.__class__:
self.sniff_order.remove( sniffer_class )
@@ -463,10 +466,10 @@
target_datatype = elem[2]
if installed_repository_dict:
converter_path = installed_repository_dict[ 'converter_path' ]
+ else:
+ converter_path = self.converters_path
+ try:
config_path = os.path.join( converter_path, tool_config )
- else:
- config_path = os.path.join( self.converters_path, tool_config )
- try:
converter = toolbox.load_tool( config_path )
if installed_repository_dict:
# If the converter is included in an installed tool shed repository, set the tool
@@ -484,7 +487,8 @@
converter.id = tool_dict[ 'guid' ]
break
if deactivate:
- del toolbox.tools_by_id[ converter.id ]
+ if converter.id in toolbox.tools_by_id:
+ del toolbox.tools_by_id[ converter.id ]
if source_datatype in self.datatype_converters:
del self.datatype_converters[ source_datatype ][ target_datatype ]
self.log.debug( "Deactivated converter: %s", converter.id )
@@ -496,9 +500,9 @@
self.log.debug( "Loaded converter: %s", converter.id )
except Exception, e:
if deactivate:
- self.log.exception( "Error deactivating converter (%s): %s" % ( config_path, str( e ) ) )
+ self.log.exception( "Error deactivating converter from (%s): %s" % ( converter_path, str( e ) ) )
else:
- self.log.exception( "Error loading converter (%s): %s" % ( config_path, str( e ) ) )
+ self.log.exception( "Error loading converter (%s): %s" % ( converter_path, str( e ) ) )
def load_display_applications( self, installed_repository_dict=None, deactivate=False ):
"""
If deactivate is False, add display applications from self.display_app_containers or
https://bitbucket.org/galaxy/galaxy-central/commits/0101573c8701/
Changeset: 0101573c8701
User: Dave Bouvier
Date: 2013-10-25 20:42:50
Summary: Merge fix from next-stable.
Affected #: 1 file
diff -r c432e846d53d1506dff86d914bb4c513ffaf19d5 -r 0101573c8701fc94bc848c2a785c48d4f3e484c3 lib/galaxy/datatypes/registry.py
--- a/lib/galaxy/datatypes/registry.py
+++ b/lib/galaxy/datatypes/registry.py
@@ -217,7 +217,8 @@
if sniffers:
for elem in sniffers.findall( 'sniffer' ):
# Keep an in-memory list of sniffer elems to enable persistence.
- self.sniffer_elems.append( elem )
+ if elem not in self.sniffer_elems:
+ self.sniffer_elems.append( elem )
dtype = elem.get( 'type', None )
if dtype:
try:
@@ -239,6 +240,8 @@
module = getattr( module, comp )
aclass = getattr( module, datatype_class_name )()
if deactivate:
+ if elem in self.sniffer_elems:
+ self.sniffer_elems.remove( elem )
for sniffer_class in self.sniff_order:
if sniffer_class.__class__ == aclass.__class__:
self.sniff_order.remove( sniffer_class )
@@ -463,10 +466,10 @@
target_datatype = elem[2]
if installed_repository_dict:
converter_path = installed_repository_dict[ 'converter_path' ]
+ else:
+ converter_path = self.converters_path
+ try:
config_path = os.path.join( converter_path, tool_config )
- else:
- config_path = os.path.join( self.converters_path, tool_config )
- try:
converter = toolbox.load_tool( config_path )
if installed_repository_dict:
# If the converter is included in an installed tool shed repository, set the tool
@@ -484,7 +487,8 @@
converter.id = tool_dict[ 'guid' ]
break
if deactivate:
- del toolbox.tools_by_id[ converter.id ]
+ if converter.id in toolbox.tools_by_id:
+ del toolbox.tools_by_id[ converter.id ]
if source_datatype in self.datatype_converters:
del self.datatype_converters[ source_datatype ][ target_datatype ]
self.log.debug( "Deactivated converter: %s", converter.id )
@@ -496,9 +500,9 @@
self.log.debug( "Loaded converter: %s", converter.id )
except Exception, e:
if deactivate:
- self.log.exception( "Error deactivating converter (%s): %s" % ( config_path, str( e ) ) )
+ self.log.exception( "Error deactivating converter from (%s): %s" % ( converter_path, str( e ) ) )
else:
- self.log.exception( "Error loading converter (%s): %s" % ( config_path, str( e ) ) )
+ self.log.exception( "Error loading converter (%s): %s" % ( converter_path, str( e ) ) )
def load_display_applications( self, installed_repository_dict=None, deactivate=False ):
"""
If deactivate is False, add display applications from self.display_app_containers or
https://bitbucket.org/galaxy/galaxy-central/commits/870a79ce1a10/
Changeset: 870a79ce1a10
Branch: next-stable
User: Dave Bouvier
Date: 2013-10-25 20:45:29
Summary: Correctly handle extracting a tarball that does contain all files and directories within a single directory at the root of the archive, but does not contain an entry for the directory itself.
Affected #: 1 file
diff -r 0255f2f29a2ba9fd047c89be919453ea90ab731f -r 870a79ce1a1048ec941b4ea298b3422ade4fc9e6 lib/tool_shed/galaxy_install/tool_dependencies/td_common_util.py
--- a/lib/tool_shed/galaxy_install/tool_dependencies/td_common_util.py
+++ b/lib/tool_shed/galaxy_install/tool_dependencies/td_common_util.py
@@ -43,31 +43,15 @@
os.makedirs( extraction_path )
self.archive.extractall( extraction_path )
else:
- # Sort filenames within the archive by length, because if the shortest path entry in the archive is a directory,
- # and the next entry has the directory prepended, then everything following that entry must be within that directory.
- # For example, consider tarball for BWA 0.5.9:
- # bwa-0.5.9.tar.bz2:
- # bwa-0.5.9/
- # bwa-0.5.9/bwt.c
- # bwa-0.5.9/bwt.h
- # bwa-0.5.9/Makefile
- # bwa-0.5.9/bwt_gen/
- # bwa-0.5.9/bwt_gen/Makefile
- # bwa-0.5.9/bwt_gen/bwt_gen.c
- # bwa-0.5.9/bwt_gen/bwt_gen.h
- # When sorted by length, one sees a directory at the root of the tarball, and all other tarball contents as
- # children of that directory.
- filenames = sorted( [ self.getname( item ) for item in contents ], cmp=lambda a,b: cmp( len( a ), len( b ) ) )
- parent_name = filenames[ 0 ]
- parent = self.getmember( parent_name )
- first_child = filenames[ 1 ]
- if first_child.startswith( parent_name ) and parent is not None and self.isdir( parent ):
- if self.getname( parent ) == self.file_name:
- self.archive.extractall( os.path.join( path ) )
- extraction_path = os.path.join( path, self.file_name )
- else:
- self.archive.extractall( os.path.join( path ) )
- extraction_path = os.path.join( path, self.getname( parent ) )
+ # Get the common prefix for all the files in the archive. If the common prefix ends with a slash,
+ # or self.isdir() returns True, the archive contains a single directory with the desired contents.
+ # Otherwise, it contains multiple files and/or directories at the root of the archive.
+ common_prefix = os.path.commonprefix( [ self.getname( item ) for item in contents ] )
+ if len( common_prefix ) >= 1 and not common_prefix.endswith( os.sep ) and self.isdir( self.getmember( common_prefix ) ):
+ common_prefix += os.sep
+ if common_prefix.endswith( os.sep ):
+ self.archive.extractall( os.path.join( path ) )
+ extraction_path = os.path.join( path, common_prefix )
else:
extraction_path = os.path.join( path, self.file_name )
if not os.path.exists( extraction_path ):
https://bitbucket.org/galaxy/galaxy-central/commits/a27073465c2f/
Changeset: a27073465c2f
User: Dave Bouvier
Date: 2013-10-25 20:46:48
Summary: Merge fix from next-stable.
Affected #: 1 file
diff -r 0101573c8701fc94bc848c2a785c48d4f3e484c3 -r a27073465c2f4925012e1df12e19321aed2b9f4a lib/tool_shed/galaxy_install/tool_dependencies/td_common_util.py
--- a/lib/tool_shed/galaxy_install/tool_dependencies/td_common_util.py
+++ b/lib/tool_shed/galaxy_install/tool_dependencies/td_common_util.py
@@ -43,31 +43,15 @@
os.makedirs( extraction_path )
self.archive.extractall( extraction_path )
else:
- # Sort filenames within the archive by length, because if the shortest path entry in the archive is a directory,
- # and the next entry has the directory prepended, then everything following that entry must be within that directory.
- # For example, consider tarball for BWA 0.5.9:
- # bwa-0.5.9.tar.bz2:
- # bwa-0.5.9/
- # bwa-0.5.9/bwt.c
- # bwa-0.5.9/bwt.h
- # bwa-0.5.9/Makefile
- # bwa-0.5.9/bwt_gen/
- # bwa-0.5.9/bwt_gen/Makefile
- # bwa-0.5.9/bwt_gen/bwt_gen.c
- # bwa-0.5.9/bwt_gen/bwt_gen.h
- # When sorted by length, one sees a directory at the root of the tarball, and all other tarball contents as
- # children of that directory.
- filenames = sorted( [ self.getname( item ) for item in contents ], cmp=lambda a,b: cmp( len( a ), len( b ) ) )
- parent_name = filenames[ 0 ]
- parent = self.getmember( parent_name )
- first_child = filenames[ 1 ]
- if first_child.startswith( parent_name ) and parent is not None and self.isdir( parent ):
- if self.getname( parent ) == self.file_name:
- self.archive.extractall( os.path.join( path ) )
- extraction_path = os.path.join( path, self.file_name )
- else:
- self.archive.extractall( os.path.join( path ) )
- extraction_path = os.path.join( path, self.getname( parent ) )
+ # Get the common prefix for all the files in the archive. If the common prefix ends with a slash,
+ # or self.isdir() returns True, the archive contains a single directory with the desired contents.
+ # Otherwise, it contains multiple files and/or directories at the root of the archive.
+ common_prefix = os.path.commonprefix( [ self.getname( item ) for item in contents ] )
+ if len( common_prefix ) >= 1 and not common_prefix.endswith( os.sep ) and self.isdir( self.getmember( common_prefix ) ):
+ common_prefix += os.sep
+ if common_prefix.endswith( os.sep ):
+ self.archive.extractall( os.path.join( path ) )
+ extraction_path = os.path.join( path, common_prefix )
else:
extraction_path = os.path.join( path, self.file_name )
if not os.path.exists( extraction_path ):
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
2 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/8109823f43c3/
Changeset: 8109823f43c3
Branch: next-stable
User: dan
Date: 2013-10-25 17:51:37
Summary: Fix for Javascript requiring setting a user/public name during registration
Affected #: 1 file
diff -r 94aea2327373d4cb651e3db3fe5113a5b0c669f5 -r 8109823f43c30a7efa744471b657efbc9624b218 templates/user/register.mako
--- a/templates/user/register.mako
+++ b/templates/user/register.mako
@@ -75,7 +75,7 @@
var error_text_password_short = 'Please use a password of at least 6 characters';
var error_text_password_match = "Passwords don't match";
- var validForm = true;
+ var validForm = true;
var email = $('#email_input').val();
var name = $('#name_input').val()
@@ -83,7 +83,7 @@
else if (!validateString(email,"email")){ renderError(error_text_email); validForm = false;}
else if (!($('#password_input').val() === $('#password_check_input').val())){ renderError(error_text_password_match); validForm = false;}
else if ($('#password_input').val().length < 6 ){ renderError(error_text_password_short); validForm = false;}
- else if (!(validateString(name,"username"))){ renderError(error_text_username_characters); validForm = false;}
+ else if (name && !(validateString(name,"username"))){ renderError(error_text_username_characters); validForm = false;}
if (!validForm) {
e.preventDefault();
https://bitbucket.org/galaxy/galaxy-central/commits/c432e846d53d/
Changeset: c432e846d53d
User: dan
Date: 2013-10-25 17:52:03
Summary: merge next-stable
Affected #: 3 files
diff -r 6865031ea0c473984473e57100f60a3739065ca1 -r c432e846d53d1506dff86d914bb4c513ffaf19d5 templates/user/register.mako
--- a/templates/user/register.mako
+++ b/templates/user/register.mako
@@ -75,7 +75,7 @@
var error_text_password_short = 'Please use a password of at least 6 characters';
var error_text_password_match = "Passwords don't match";
- var validForm = true;
+ var validForm = true;
var email = $('#email_input').val();
var name = $('#name_input').val()
@@ -83,7 +83,7 @@
else if (!validateString(email,"email")){ renderError(error_text_email); validForm = false;}
else if (!($('#password_input').val() === $('#password_check_input').val())){ renderError(error_text_password_match); validForm = false;}
else if ($('#password_input').val().length < 6 ){ renderError(error_text_password_short); validForm = false;}
- else if (!(validateString(name,"username"))){ renderError(error_text_username_characters); validForm = false;}
+ else if (name && !(validateString(name,"username"))){ renderError(error_text_username_characters); validForm = false;}
if (!validForm) {
e.preventDefault();
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/6865031ea0c4/
Changeset: 6865031ea0c4
User: greg
Date: 2013-10-25 17:06:28
Summary: Display an error message rather than raising an exception when a changeset being committed to a tool shed repository includes a dependency definition that has an invalid <repository> tag set.
Affected #: 3 files
diff -r d57971b60b8d907c33bf4dfc1bba2432baaf96e9 -r 6865031ea0c473984473e57100f60a3739065ca1 lib/galaxy/webapps/tool_shed/controllers/upload.py
--- a/lib/galaxy/webapps/tool_shed/controllers/upload.py
+++ b/lib/galaxy/webapps/tool_shed/controllers/upload.py
@@ -135,8 +135,14 @@
# Move some version of the uploaded file to the load_point within the repository hierarchy.
if uploaded_file_filename in [ suc.REPOSITORY_DEPENDENCY_DEFINITION_FILENAME ]:
# Inspect the contents of the file to see if changeset_revision values are missing and if so, set them appropriately.
- altered, root_elem = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name, unpopulate=False )
- if altered:
+ altered, root_elem, error_message = commit_util.handle_repository_dependencies_definition( trans,
+ uploaded_file_name,
+ unpopulate=False )
+ if error_message:
+ ok = False
+ message = error_message
+ status = 'error'
+ elif altered:
tmp_filename = xml_util.create_and_write_tmp_file( root_elem )
shutil.move( tmp_filename, full_path )
else:
@@ -152,26 +158,31 @@
shutil.move( uploaded_file_name, full_path )
else:
shutil.move( uploaded_file_name, full_path )
- # See if any admin users have chosen to receive email alerts when a repository is updated. If so, check every uploaded file to ensure
- # content is appropriate.
- check_contents = commit_util.check_file_contents_for_email_alerts( trans )
- if check_contents and os.path.isfile( full_path ):
- content_alert_str = commit_util.check_file_content_for_html_and_images( full_path )
- else:
- content_alert_str = ''
- commands.add( repo.ui, repo, full_path )
- # Convert from unicode to prevent "TypeError: array item must be char"
- full_path = full_path.encode( 'ascii', 'replace' )
- commands.commit( repo.ui, repo, full_path, user=trans.user.username, message=commit_message )
- if full_path.endswith( 'tool_data_table_conf.xml.sample' ):
- # Handle the special case where a tool_data_table_conf.xml.sample file is being uploaded by parsing the file and adding new entries
- # to the in-memory trans.app.tool_data_tables dictionary.
- error, error_message = tool_util.handle_sample_tool_data_table_conf_file( trans.app, full_path )
- if error:
- message = '%s<br/>%s' % ( message, error_message )
- # See if the content of the change set was valid.
- admin_only = len( repository.downloadable_revisions ) != 1
- suc.handle_email_alerts( trans, repository, content_alert_str=content_alert_str, new_repo_alert=new_repo_alert, admin_only=admin_only )
+ if ok:
+ # See if any admin users have chosen to receive email alerts when a repository is updated. If so, check every uploaded file to ensure
+ # content is appropriate.
+ check_contents = commit_util.check_file_contents_for_email_alerts( trans )
+ if check_contents and os.path.isfile( full_path ):
+ content_alert_str = commit_util.check_file_content_for_html_and_images( full_path )
+ else:
+ content_alert_str = ''
+ commands.add( repo.ui, repo, full_path )
+ # Convert from unicode to prevent "TypeError: array item must be char"
+ full_path = full_path.encode( 'ascii', 'replace' )
+ commands.commit( repo.ui, repo, full_path, user=trans.user.username, message=commit_message )
+ if full_path.endswith( 'tool_data_table_conf.xml.sample' ):
+ # Handle the special case where a tool_data_table_conf.xml.sample file is being uploaded by parsing the file and adding new entries
+ # to the in-memory trans.app.tool_data_tables dictionary.
+ error, error_message = tool_util.handle_sample_tool_data_table_conf_file( trans.app, full_path )
+ if error:
+ message = '%s<br/>%s' % ( message, error_message )
+ # See if the content of the change set was valid.
+ admin_only = len( repository.downloadable_revisions ) != 1
+ suc.handle_email_alerts( trans,
+ repository,
+ content_alert_str=content_alert_str,
+ new_repo_alert=new_repo_alert,
+ admin_only=admin_only )
if ok:
# Update the repository files for browsing.
suc.update_repository( repo )
@@ -283,8 +294,12 @@
uploaded_file_name = os.path.abspath( os.path.join( root, uploaded_file ) )
if os.path.split( uploaded_file_name )[ -1 ] == suc.REPOSITORY_DEPENDENCY_DEFINITION_FILENAME:
# Inspect the contents of the file to see if changeset_revision values are missing and if so, set them appropriately.
- altered, root_elem = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name, unpopulate=False )
- if altered:
+ altered, root_elem, error_message = commit_util.handle_repository_dependencies_definition( trans,
+ uploaded_file_name,
+ unpopulate=False )
+ if error_message:
+ return False, error_message, [], '', [], []
+ elif altered:
tmp_filename = xml_util.create_and_write_tmp_file( root_elem )
shutil.move( tmp_filename, uploaded_file_name )
elif os.path.split( uploaded_file_name )[ -1 ] == suc.TOOL_DEPENDENCY_DEFINITION_FILENAME:
@@ -344,8 +359,12 @@
uploaded_file_name = os.path.join( full_path, filename )
if os.path.split( uploaded_file_name )[ -1 ] == suc.REPOSITORY_DEPENDENCY_DEFINITION_FILENAME:
# Inspect the contents of the file to see if changeset_revision values are missing and if so, set them appropriately.
- altered, root_elem = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name, unpopulate=False )
- if altered:
+ altered, root_elem, error_message = commit_util.handle_repository_dependencies_definition( trans,
+ uploaded_file_name,
+ unpopulate=False )
+ if error_message:
+ return False, error_message, [], '', [], []
+ elif altered:
tmp_filename = xml_util.create_and_write_tmp_file( root_elem )
shutil.move( tmp_filename, uploaded_file_name )
elif os.path.split( uploaded_file_name )[ -1 ] == suc.TOOL_DEPENDENCY_DEFINITION_FILENAME:
diff -r d57971b60b8d907c33bf4dfc1bba2432baaf96e9 -r 6865031ea0c473984473e57100f60a3739065ca1 lib/tool_shed/util/commit_util.py
--- a/lib/tool_shed/util/commit_util.py
+++ b/lib/tool_shed/util/commit_util.py
@@ -257,7 +257,7 @@
# Make sure we're looking at a valid repository_dependencies.xml file.
tree, error_message = xml_util.parse_xml( repository_dependencies_config )
if tree is None:
- return False, None
+ return False, None, error_message
root = tree.getroot()
if root.tag == 'repositories':
for index, elem in enumerate( root ):
@@ -265,14 +265,14 @@
# <repository name="molecule_datatypes" owner="test" changeset_revision="1a070566e9c6" />
revised, elem, error_message = handle_repository_dependency_elem( trans, elem, unpopulate=unpopulate )
if error_message:
- exception_message = 'The repository_dependencies.xml file contains an invalid <repository> tag. %s' % error_message
- raise Exception( exception_message )
+ error_message = 'The repository_dependencies.xml file contains an invalid <repository> tag. %s' % error_message
+ return False, None, error_message
if revised:
root[ index ] = elem
if not altered:
altered = True
- return altered, root
- return False, None
+ return altered, root, error_message
+ return False, None, error_message
def handle_repository_dependency_elem( trans, elem, unpopulate=False ):
# <repository name="molecule_datatypes" owner="test" changeset_revision="1a070566e9c6" />
diff -r d57971b60b8d907c33bf4dfc1bba2432baaf96e9 -r 6865031ea0c473984473e57100f60a3739065ca1 lib/tool_shed/util/export_util.py
--- a/lib/tool_shed/util/export_util.py
+++ b/lib/tool_shed/util/export_util.py
@@ -142,7 +142,9 @@
# See if we have a repository dependencies defined.
if name == suc.REPOSITORY_DEPENDENCY_DEFINITION_FILENAME:
# Eliminate the toolshed, and changeset_revision attributes from all <repository> tags.
- altered, root_elem = commit_util.handle_repository_dependencies_definition( trans, full_path, unpopulate=True )
+ altered, root_elem, error_message = commit_util.handle_repository_dependencies_definition( trans, full_path, unpopulate=True )
+ if error_message:
+ return None, error_message
if altered:
tmp_filename = xml_util.create_and_write_tmp_file( root_elem, use_indent=True )
shutil.move( tmp_filename, full_path )
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
2 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/21a13e4865b3/
Changeset: 21a13e4865b3
Branch: next-stable
User: jmchilton
Date: 2013-04-23 16:57:14
Summary: Add exception handling for Binary sniffers. Image sniffers can fail for large files because signed integers are used internally, this catches that and other potential problems.
Traceback (most recent call last):
File "/opt/galaxy/web/tools/data_source/upload.py", line 432, in <module>
__main__()
File "/opt/galaxy/web/tools/data_source/upload.py", line 421, in __main__
add_file( dataset, registry, json_file, output_path )
File "/opt/galaxy/web/tools/data_source/upload.py", line 155, in add_file
type_info = Binary.is_sniffable_binary( dataset.path )
File "/opt/galaxy/web/lib/galaxy/datatypes/binary.py", line 38, in is_sniffable_binary
if format["class"]().sniff(filename):
File "/opt/galaxy/web/lib/galaxy/datatypes/images.py", line 203, in sniff
headers = get_headers(filename, None, 1)
File "/opt/galaxy/web/lib/galaxy/datatypes/sniff.py", line 179, in get_headers
for idx, line in enumerate(file(fname)):
SystemError: Negative size passed to PyString_FromStringAndSize
Affected #: 1 file
diff -r 7266b5e09cb20cac801cddef87b0466ddc32d41e -r 21a13e4865b3f5d997dd34bc977eb5f998b43024 lib/galaxy/datatypes/binary.py
--- a/lib/galaxy/datatypes/binary.py
+++ b/lib/galaxy/datatypes/binary.py
@@ -42,11 +42,20 @@
Binary.unsniffable_binary_formats.append(ext)
@staticmethod
- def is_sniffable_binary(filename):
+ def is_sniffable_binary( filename ):
+ format_information = None
for format in Binary.sniffable_binary_formats:
- if format["class"]().sniff(filename):
- return (format["type"], format["ext"])
- return None
+ format_instance = format[ "class" ]()
+ try:
+ if format_instance.sniff(filename):
+ format_information = ( format["type"], format[ "ext" ] )
+ break
+ except Exception:
+ # Sniffer raised exception, could be any number of
+ # reasons for this so there is not much to do besides
+ # trying next sniffer.
+ pass
+ return format_information
@staticmethod
def is_ext_unsniffable(ext):
https://bitbucket.org/galaxy/galaxy-central/commits/94aea2327373/
Changeset: 94aea2327373
Branch: next-stable
User: jmchilton
Date: 2013-04-23 19:24:16
Summary: Rework checking binary files. Why read in line by line if only going to check 100 characters? This approach to just read first 100 characters is cleaner, more efficient, and hopefully less error prone. Should avoid the following exception caused when checking large files:
Traceback (most recent call last):
File "/opt/galaxy/web/tools/data_source/upload.py", line 432, in <module>
__main__()
File "/opt/galaxy/web/tools/data_source/upload.py", line 421, in __main__
add_file( dataset, registry, json_file, output_path )
File "/opt/galaxy/web/tools/data_source/upload.py", line 283, in add_file
if check_binary( dataset.path ):
File "/opt/galaxy/web/lib/galaxy/datatypes/checkers.py", line 58, in check_binary
for chars in temp:
SystemError: Negative size passed to PyString_FromStringAndSize
Affected #: 1 file
diff -r 21a13e4865b3f5d997dd34bc977eb5f998b43024 -r 94aea2327373d4cb651e3db3fe5113a5b0c669f5 lib/galaxy/datatypes/checkers.py
--- a/lib/galaxy/datatypes/checkers.py
+++ b/lib/galaxy/datatypes/checkers.py
@@ -1,5 +1,6 @@
import os, gzip, re, gzip, zipfile, binascii, bz2, imghdr
from galaxy import util
+from StringIO import StringIO
try:
import Image as PIL
@@ -53,20 +54,15 @@
if file_path:
temp = open( name, "U" )
else:
- temp = name
+ temp = StringIO( name )
chars_read = 0
- for chars in temp:
- for char in chars:
- chars_read += 1
+ try:
+ for char in temp.read( 100 ):
if util.is_binary( char ):
is_binary = True
break
- if chars_read > 100:
- break
- if chars_read > 100:
- break
- if file_path:
- temp.close()
+ finally:
+ temp.close( )
return is_binary
def check_gzip( file_path ):
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.