2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/e7e82003f235/ Changeset: e7e82003f235 Branch: next-stable User: natefoo Date: 2013-08-08 21:40:00 Summary: Define the ActionInputError exception that was being caught in the quotas API controller. Thanks Jim Johnson. Affected #: 3 files diff -r 8d8429484ac3ffef21fedd1077acf050c8aed459 -r e7e82003f235c4cca84939e04aa432d128093866 lib/galaxy/actions/admin.py --- a/lib/galaxy/actions/admin.py +++ b/lib/galaxy/actions/admin.py @@ -4,7 +4,7 @@ import logging from galaxy import util -from galaxy.exceptions import MessageException +from galaxy.exceptions import ActionInputError log = logging.getLogger( __name__ ) @@ -21,21 +21,21 @@ except AssertionError: create_amount = False if not params.name or not params.description: - raise MessageException( "Enter a valid name and a description.", type='error' ) + raise ActionInputError( "Enter a valid name and a description." ) elif self.sa_session.query( self.app.model.Quota ).filter( self.app.model.Quota.table.c.name==params.name ).first(): - raise MessageException( "Quota names must be unique and a quota with that name already exists, so choose another name.", type='error' ) + raise ActionInputError( "Quota names must be unique and a quota with that name already exists, so choose another name." ) elif not params.get( 'amount', None ): - raise MessageException( "Enter a valid quota amount.", type='error' ) + raise ActionInputError( "Enter a valid quota amount." ) elif create_amount is False: - raise MessageException( "Unable to parse the provided amount.", type='error' ) + raise ActionInputError( "Unable to parse the provided amount." ) elif params.operation not in self.app.model.Quota.valid_operations: - raise MessageException( "Enter a valid operation.", type='error' ) + raise ActionInputError( "Enter a valid operation." ) elif params.default != 'no' and params.default not in self.app.model.DefaultQuotaAssociation.types.__dict__.values(): - raise MessageException( "Enter a valid default type.", type='error' ) + raise ActionInputError( "Enter a valid default type." ) elif params.default != 'no' and params.operation != '=': - raise MessageException( "Operation for a default quota must be '='.", type='error' ) + raise ActionInputError( "Operation for a default quota must be '='." ) elif create_amount is None and params.operation != '=': - raise MessageException( "Operation for an unlimited quota must be '='.", type='error' ) + raise ActionInputError( "Operation for an unlimited quota must be '='." ) else: # Create the quota quota = self.app.model.Quota( name=params.name, description=params.description, amount=create_amount, operation=params.operation ) @@ -59,9 +59,9 @@ def _rename_quota( self, quota, params ): if not params.name: - raise MessageException( 'Enter a valid name', type='error' ) + raise ActionInputError( 'Enter a valid name' ) elif params.name != quota.name and self.sa_session.query( self.app.model.Quota ).filter( self.app.model.Quota.table.c.name==params.name ).first(): - raise MessageException( 'A quota with that name already exists', type='error' ) + raise ActionInputError( 'A quota with that name already exists' ) else: old_name = quota.name quota.name = params.name @@ -73,7 +73,7 @@ def _manage_users_and_groups_for_quota( self, quota, params ): if quota.default: - raise MessageException( 'Default quotas cannot be associated with specific users and groups', type='error' ) + raise ActionInputError( 'Default quotas cannot be associated with specific users and groups' ) else: in_users = [ self.sa_session.query( self.app.model.User ).get( x ) for x in util.listify( params.in_users ) ] in_groups = [ self.sa_session.query( self.app.model.Group ).get( x ) for x in util.listify( params.in_groups ) ] @@ -91,11 +91,11 @@ except AssertionError: new_amount = False if not params.amount: - raise MessageException( 'Enter a valid amount', type='error' ) + raise ActionInputError( 'Enter a valid amount' ) elif new_amount is False: - raise MessageException( 'Unable to parse the provided amount', type='error' ) + raise ActionInputError( 'Unable to parse the provided amount' ) elif params.operation not in self.app.model.Quota.valid_operations: - raise MessageException( 'Enter a valid operation', type='error' ) + raise ActionInputError( 'Enter a valid operation' ) else: quota.amount = new_amount quota.operation = params.operation @@ -106,7 +106,7 @@ def _set_quota_default( self, quota, params ): if params.default != 'no' and params.default not in self.app.model.DefaultQuotaAssociation.types.__dict__.values(): - raise MessageException( 'Enter a valid default type.', type='error' ) + raise ActionInputError( 'Enter a valid default type.' ) else: if params.default != 'no': self.app.quota_agent.set_default_quota( params.default, quota ) @@ -123,7 +123,7 @@ def _unset_quota_default( self, quota, params ): if not quota.default: - raise MessageException( "Quota '%s' is not a default." % quota.name, type='error' ) + raise ActionInputError( "Quota '%s' is not a default." % quota.name ) else: message = "Quota '%s' is no longer the default for %s users." % ( quota.name, quota.default[0].type ) for dqa in quota.default: @@ -138,9 +138,9 @@ if q.default: names.append( q.name ) if len( names ) == 1: - raise MessageException( "Quota '%s' is a default, please unset it as a default before deleting it" % ( names[0] ), type='error' ) + raise ActionInputError( "Quota '%s' is a default, please unset it as a default before deleting it" % ( names[0] ) ) elif len( names ) > 1: - raise MessageException( "Quotas are defaults, please unset them as defaults before deleting them: " + ', '.join( names ), type='error' ) + raise ActionInputError( "Quotas are defaults, please unset them as defaults before deleting them: " + ', '.join( names ) ) message = "Deleted %d quotas: " % len( quotas ) for q in quotas: q.deleted = True @@ -157,9 +157,9 @@ if not q.deleted: names.append( q.name ) if len( names ) == 1: - raise MessageException( "Quota '%s' has not been deleted, so it cannot be undeleted." % ( names[0] ), type='error' ) + raise ActionInputError( "Quota '%s' has not been deleted, so it cannot be undeleted." % ( names[0] ) ) elif len( names ) > 1: - raise MessageException( "Quotas have not been deleted so they cannot be undeleted: " + ', '.join( names ), type='error' ) + raise ActionInputError( "Quotas have not been deleted so they cannot be undeleted: " + ', '.join( names ) ) message = "Undeleted %d quotas: " % len( quotas ) for q in quotas: q.deleted = False @@ -182,9 +182,9 @@ if not q.deleted: names.append( q.name ) if len( names ) == 1: - raise MessageException( "Quota '%s' has not been deleted, so it cannot be purged." % ( names[0] ), type='error' ) + raise ActionInputError( "Quota '%s' has not been deleted, so it cannot be purged." % ( names[0] ) ) elif len( names ) > 1: - raise MessageException( "Quotas have not been deleted so they cannot be undeleted: " + ', '.join( names ), type='error' ) + raise ActionInputError( "Quotas have not been deleted so they cannot be undeleted: " + ', '.join( names ) ) message = "Purged %d quotas: " % len( quotas ) for q in quotas: # Delete UserQuotaAssociations diff -r 8d8429484ac3ffef21fedd1077acf050c8aed459 -r e7e82003f235c4cca84939e04aa432d128093866 lib/galaxy/exceptions/__init__.py --- a/lib/galaxy/exceptions/__init__.py +++ b/lib/galaxy/exceptions/__init__.py @@ -21,6 +21,10 @@ class ItemOwnershipException( MessageException ): pass +class ActionInputError( MessageException ): + def __init__( self, err_msg, type="error" ): + super( ActionInputError, self ).__init__( err_msg, type ) + class ObjectNotFound( Exception ): """ Accessed object was not found """ pass diff -r 8d8429484ac3ffef21fedd1077acf050c8aed459 -r e7e82003f235c4cca84939e04aa432d128093866 lib/galaxy/webapps/galaxy/api/quotas.py --- a/lib/galaxy/webapps/galaxy/api/quotas.py +++ b/lib/galaxy/webapps/galaxy/api/quotas.py @@ -11,7 +11,7 @@ from galaxy.actions.admin import AdminActions from paste.httpexceptions import HTTPBadRequest -from galaxy.exceptions import * +from galaxy.exceptions import ActionInputError log = logging.getLogger( __name__ ) https://bitbucket.org/galaxy/galaxy-central/commits/61ddd0d07950/ Changeset: 61ddd0d07950 User: natefoo Date: 2013-08-08 21:50:05 Summary: Merge next-stable. Affected #: 3 files diff -r 3778811f053a5f71c68408a9e8beb627f6ccdede -r 61ddd0d07950fafc18fed95354459e7715e6b1d7 lib/galaxy/actions/admin.py --- a/lib/galaxy/actions/admin.py +++ b/lib/galaxy/actions/admin.py @@ -4,7 +4,7 @@ import logging from galaxy import util -from galaxy.exceptions import MessageException +from galaxy.exceptions import ActionInputError log = logging.getLogger( __name__ ) @@ -21,21 +21,21 @@ except AssertionError: create_amount = False if not params.name or not params.description: - raise MessageException( "Enter a valid name and a description.", type='error' ) + raise ActionInputError( "Enter a valid name and a description." ) elif self.sa_session.query( self.app.model.Quota ).filter( self.app.model.Quota.table.c.name==params.name ).first(): - raise MessageException( "Quota names must be unique and a quota with that name already exists, so choose another name.", type='error' ) + raise ActionInputError( "Quota names must be unique and a quota with that name already exists, so choose another name." ) elif not params.get( 'amount', None ): - raise MessageException( "Enter a valid quota amount.", type='error' ) + raise ActionInputError( "Enter a valid quota amount." ) elif create_amount is False: - raise MessageException( "Unable to parse the provided amount.", type='error' ) + raise ActionInputError( "Unable to parse the provided amount." ) elif params.operation not in self.app.model.Quota.valid_operations: - raise MessageException( "Enter a valid operation.", type='error' ) + raise ActionInputError( "Enter a valid operation." ) elif params.default != 'no' and params.default not in self.app.model.DefaultQuotaAssociation.types.__dict__.values(): - raise MessageException( "Enter a valid default type.", type='error' ) + raise ActionInputError( "Enter a valid default type." ) elif params.default != 'no' and params.operation != '=': - raise MessageException( "Operation for a default quota must be '='.", type='error' ) + raise ActionInputError( "Operation for a default quota must be '='." ) elif create_amount is None and params.operation != '=': - raise MessageException( "Operation for an unlimited quota must be '='.", type='error' ) + raise ActionInputError( "Operation for an unlimited quota must be '='." ) else: # Create the quota quota = self.app.model.Quota( name=params.name, description=params.description, amount=create_amount, operation=params.operation ) @@ -59,9 +59,9 @@ def _rename_quota( self, quota, params ): if not params.name: - raise MessageException( 'Enter a valid name', type='error' ) + raise ActionInputError( 'Enter a valid name' ) elif params.name != quota.name and self.sa_session.query( self.app.model.Quota ).filter( self.app.model.Quota.table.c.name==params.name ).first(): - raise MessageException( 'A quota with that name already exists', type='error' ) + raise ActionInputError( 'A quota with that name already exists' ) else: old_name = quota.name quota.name = params.name @@ -73,7 +73,7 @@ def _manage_users_and_groups_for_quota( self, quota, params ): if quota.default: - raise MessageException( 'Default quotas cannot be associated with specific users and groups', type='error' ) + raise ActionInputError( 'Default quotas cannot be associated with specific users and groups' ) else: in_users = [ self.sa_session.query( self.app.model.User ).get( x ) for x in util.listify( params.in_users ) ] in_groups = [ self.sa_session.query( self.app.model.Group ).get( x ) for x in util.listify( params.in_groups ) ] @@ -91,11 +91,11 @@ except AssertionError: new_amount = False if not params.amount: - raise MessageException( 'Enter a valid amount', type='error' ) + raise ActionInputError( 'Enter a valid amount' ) elif new_amount is False: - raise MessageException( 'Unable to parse the provided amount', type='error' ) + raise ActionInputError( 'Unable to parse the provided amount' ) elif params.operation not in self.app.model.Quota.valid_operations: - raise MessageException( 'Enter a valid operation', type='error' ) + raise ActionInputError( 'Enter a valid operation' ) else: quota.amount = new_amount quota.operation = params.operation @@ -106,7 +106,7 @@ def _set_quota_default( self, quota, params ): if params.default != 'no' and params.default not in self.app.model.DefaultQuotaAssociation.types.__dict__.values(): - raise MessageException( 'Enter a valid default type.', type='error' ) + raise ActionInputError( 'Enter a valid default type.' ) else: if params.default != 'no': self.app.quota_agent.set_default_quota( params.default, quota ) @@ -123,7 +123,7 @@ def _unset_quota_default( self, quota, params ): if not quota.default: - raise MessageException( "Quota '%s' is not a default." % quota.name, type='error' ) + raise ActionInputError( "Quota '%s' is not a default." % quota.name ) else: message = "Quota '%s' is no longer the default for %s users." % ( quota.name, quota.default[0].type ) for dqa in quota.default: @@ -138,9 +138,9 @@ if q.default: names.append( q.name ) if len( names ) == 1: - raise MessageException( "Quota '%s' is a default, please unset it as a default before deleting it" % ( names[0] ), type='error' ) + raise ActionInputError( "Quota '%s' is a default, please unset it as a default before deleting it" % ( names[0] ) ) elif len( names ) > 1: - raise MessageException( "Quotas are defaults, please unset them as defaults before deleting them: " + ', '.join( names ), type='error' ) + raise ActionInputError( "Quotas are defaults, please unset them as defaults before deleting them: " + ', '.join( names ) ) message = "Deleted %d quotas: " % len( quotas ) for q in quotas: q.deleted = True @@ -157,9 +157,9 @@ if not q.deleted: names.append( q.name ) if len( names ) == 1: - raise MessageException( "Quota '%s' has not been deleted, so it cannot be undeleted." % ( names[0] ), type='error' ) + raise ActionInputError( "Quota '%s' has not been deleted, so it cannot be undeleted." % ( names[0] ) ) elif len( names ) > 1: - raise MessageException( "Quotas have not been deleted so they cannot be undeleted: " + ', '.join( names ), type='error' ) + raise ActionInputError( "Quotas have not been deleted so they cannot be undeleted: " + ', '.join( names ) ) message = "Undeleted %d quotas: " % len( quotas ) for q in quotas: q.deleted = False @@ -182,9 +182,9 @@ if not q.deleted: names.append( q.name ) if len( names ) == 1: - raise MessageException( "Quota '%s' has not been deleted, so it cannot be purged." % ( names[0] ), type='error' ) + raise ActionInputError( "Quota '%s' has not been deleted, so it cannot be purged." % ( names[0] ) ) elif len( names ) > 1: - raise MessageException( "Quotas have not been deleted so they cannot be undeleted: " + ', '.join( names ), type='error' ) + raise ActionInputError( "Quotas have not been deleted so they cannot be undeleted: " + ', '.join( names ) ) message = "Purged %d quotas: " % len( quotas ) for q in quotas: # Delete UserQuotaAssociations diff -r 3778811f053a5f71c68408a9e8beb627f6ccdede -r 61ddd0d07950fafc18fed95354459e7715e6b1d7 lib/galaxy/exceptions/__init__.py --- a/lib/galaxy/exceptions/__init__.py +++ b/lib/galaxy/exceptions/__init__.py @@ -21,6 +21,10 @@ class ItemOwnershipException( MessageException ): pass +class ActionInputError( MessageException ): + def __init__( self, err_msg, type="error" ): + super( ActionInputError, self ).__init__( err_msg, type ) + class ObjectNotFound( Exception ): """ Accessed object was not found """ pass diff -r 3778811f053a5f71c68408a9e8beb627f6ccdede -r 61ddd0d07950fafc18fed95354459e7715e6b1d7 lib/galaxy/webapps/galaxy/api/quotas.py --- a/lib/galaxy/webapps/galaxy/api/quotas.py +++ b/lib/galaxy/webapps/galaxy/api/quotas.py @@ -11,7 +11,7 @@ from galaxy.actions.admin import AdminActions from paste.httpexceptions import HTTPBadRequest -from galaxy.exceptions import * +from galaxy.exceptions import ActionInputError log = logging.getLogger( __name__ ) 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.