commit/galaxy-central: Dave Bouvier: Add missing hda name length check to submit_form.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/6ba6f297b969/ Changeset: 6ba6f297b969 User: Dave Bouvier Date: 2013-05-09 19:49:13 Summary: Add missing hda name length check to submit_form. Affected #: 1 file diff -r 51f4926f6dd8b837c02dd8559587342542cdd7f2 -r 6ba6f297b9694e29ff774a33e9b88b9f666ddee7 test/base/twilltestcase.py --- a/test/base/twilltestcase.py +++ b/test/base/twilltestcase.py @@ -1169,18 +1169,21 @@ # To help with debugging a tool, print out the form controls when the test fails print "form '%s' contains the following controls ( note the values )" % f.name controls = {} + formcontrols = [] hc_prefix = '<HiddenControl(' for i, control in enumerate( f.controls ): - print "control %d: %s" % ( i, str( control ) ) + formcontrols.append( "control %d: %s" % ( i, str( control ) ) ) + for i, control in enumerate( f.controls ): if not hc_prefix in str( control ): try: #check if a repeat element needs to be added - if control.name not in kwd and control.name.endswith( '_add' ): - #control name doesn't exist, could be repeat - repeat_startswith = control.name[0:-4] - if repeat_startswith and not [ c_name for c_name in controls.keys() if c_name.startswith( repeat_startswith ) ] and [ c_name for c_name in kwd.keys() if c_name.startswith( repeat_startswith ) ]: - tc.submit( control.name ) - return self.submit_form( form_no=form_no, button=button, **kwd ) + if control.name is not None: + if control.name not in kwd and control.name.endswith( '_add' ): + #control name doesn't exist, could be repeat + repeat_startswith = control.name[0:-4] + if repeat_startswith and not [ c_name for c_name in controls.keys() if c_name.startswith( repeat_startswith ) ] and [ c_name for c_name in kwd.keys() if c_name.startswith( repeat_startswith ) ]: + tc.submit( control.name ) + return self.submit_form( form_no=form_no, button=button, **kwd ) # Check for refresh_on_change attribute, submit a change if required if hasattr( control, 'attrs' ) and 'refresh_on_change' in control.attrs.keys(): changed = False @@ -1188,9 +1191,10 @@ # This loop gets the filename/label for the selected values. item_labels = [ item.attrs[ 'label' ] for item in control.get_items() if item.selected ] for value in kwd[ control.name ]: - # Galaxy truncates long file names in the dataset_collector in galaxy/tools/parameters/basic.py + # Galaxy truncates long file names in the dataset_collector in galaxy/tools/parameters/basic.py. + # This (and other places where this is done) should be refactored to use the HDA id. if len( value ) > 30 and control.is_of_kind( 'singlelist' ): - field_value = '%s..%s' % ( elem[:17], elem[-11:] ) + field_value = '%s..%s' % ( value[:17], value[-11:] ) else: field_value = value if field_value not in control.value and True not in [ field_value in item_label for item_label in item_labels ]: @@ -1214,7 +1218,9 @@ tc.submit( '___refresh_grouping___' ) return self.submit_form( form_no=form_no, button=button, **kwd ) except Exception, e: - log.debug( "In submit_form, continuing, but caught exception: %s" % str( e ) ) + log.exception( "In submit_form, continuing, but caught exception." ) + for formcontrol in formcontrols: + log.debug( formcontrol ) continue controls[ control.name ] = control # No refresh_on_change attribute found in current form, so process as usual @@ -1254,15 +1260,25 @@ for elem in control_value: try: tc.fv( f.name, control.name, str( elem ) ) - except Exception, e2: - print "Attempting to set control '", control.name, "' to value '", elem, "' threw exception: ", e2 - # Galaxy truncates long file names in the dataset_collector in galaxy/tools/parameters/basic.py - if len( elem ) > 30: - elem_name = '%s..%s' % ( elem[:17], elem[-11:] ) - else: - elem_name = elem - tc.fv( f.name, control.name, str( elem_name ) ) + except Exception: + try: + # Galaxy truncates long file names in the dataset_collector in galaxy/tools/parameters/basic.py + if len( elem ) > 30: + elem_name = '%s..%s' % ( elem[:17], elem[-11:] ) + tc.fv( f.name, control.name, str( elem_name ) ) + pass + else: + raise + except Exception: + raise + except Exception: + for formcontrol in formcontrols: + log.debug( formcontrol ) + log.exception( "Attempting to set control '%s' to value '%s' (also tried '%s') threw exception.", control.name, elem, elem_name ) + pass except Exception, exc: + for formcontrol in formcontrols: + log.debug( formcontrol ) errmsg = "Attempting to set field '%s' to value '%s' in form '%s' threw exception: %s\n" % ( control_name, str( control_value ), f.name, str( exc ) ) errmsg += "control: %s\n" % str( control ) errmsg += "If the above control is a DataToolparameter whose data type class does not include a sniff() method,\n" @@ -1272,6 +1288,7 @@ # Add conditions for other control types here when necessary. pass tc.submit( button ) + def refresh_form( self, control_name, value, form_no=0, **kwd ): """Handles Galaxy's refresh_on_change for forms without ultimately submitting the form""" # control_name is the name of the form field that requires refresh_on_change, and value is 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.
participants (1)
-
commits-noreply@bitbucket.org