Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use modern exception construction syntax

  • Loading branch information...
commit 5d84b33e15ce30445705cf5ba34b36b09733160f 1 parent 399a41d
@gholms gholms authored garnaat committed
View
2  boto/manage/cmdshell.py
@@ -173,7 +173,7 @@ def exists(self, path):
return os.path.exists(path)
def shell(self):
- raise NotImplementedError, 'shell not supported with LocalClient'
+ raise NotImplementedError('shell not supported with LocalClient')
def run(self):
boto.log.info('running:%s' % self.command)
View
6 boto/manage/server.py
@@ -489,19 +489,19 @@ def put(self):
def delete(self):
if self.production:
- raise ValueError, "Can't delete a production server"
+ raise ValueError("Can't delete a production server")
#self.stop()
Model.delete(self)
def stop(self):
if self.production:
- raise ValueError, "Can't delete a production server"
+ raise ValueError("Can't delete a production server")
if self._instance:
self._instance.stop()
def terminate(self):
if self.production:
- raise ValueError, "Can't delete a production server"
+ raise ValueError("Can't delete a production server")
if self._instance:
self._instance.terminate()
View
8 boto/manage/volume.py
@@ -219,7 +219,7 @@ def detach(self, force=False):
def checkfs(self, use_cmd=None):
if self.server == None:
- raise ValueError, 'server attribute must be set to run this command'
+ raise ValueError('server attribute must be set to run this command')
# detemine state of file system on volume, only works if attached
if use_cmd:
cmd = use_cmd
@@ -234,7 +234,7 @@ def checkfs(self, use_cmd=None):
def wait(self):
if self.server == None:
- raise ValueError, 'server attribute must be set to run this command'
+ raise ValueError('server attribute must be set to run this command')
with closing(self.server.get_cmdshell()) as cmd:
# wait for the volume device to appear
cmd = self.server.get_cmdshell()
@@ -244,7 +244,7 @@ def wait(self):
def format(self):
if self.server == None:
- raise ValueError, 'server attribute must be set to run this command'
+ raise ValueError('server attribute must be set to run this command')
status = None
with closing(self.server.get_cmdshell()) as cmd:
if not self.checkfs(cmd):
@@ -254,7 +254,7 @@ def format(self):
def mount(self):
if self.server == None:
- raise ValueError, 'server attribute must be set to run this command'
+ raise ValueError('server attribute must be set to run this command')
boto.log.info('handle_mount_point')
with closing(self.server.get_cmdshell()) as cmd:
cmd = self.server.get_cmdshell()
View
14 boto/rds/parametergroup.py
@@ -134,11 +134,11 @@ def merge(self, d, i):
def _set_string_value(self, value):
if not isinstance(value, str) or isinstance(value, unicode):
- raise ValueError, 'value must be of type str'
+ raise ValueError('value must be of type str')
if self.allowed_values:
choices = self.allowed_values.split(',')
if value not in choices:
- raise ValueError, 'value must be in %s' % self.allowed_values
+ raise ValueError('value must be in %s' % self.allowed_values)
self._value = value
def _set_integer_value(self, value):
@@ -148,10 +148,10 @@ def _set_integer_value(self, value):
if self.allowed_values:
min, max = self.allowed_values.split('-')
if value < int(min) or value > int(max):
- raise ValueError, 'range is %s' % self.allowed_values
+ raise ValueError('range is %s' % self.allowed_values)
self._value = value
else:
- raise ValueError, 'value must be integer'
+ raise ValueError('value must be integer')
def _set_boolean_value(self, value):
if isinstance(value, bool):
@@ -162,7 +162,7 @@ def _set_boolean_value(self, value):
else:
self._value = False
else:
- raise ValueError, 'value must be boolean'
+ raise ValueError('value must be boolean')
def set_value(self, value):
if self.type == 'string':
@@ -172,7 +172,7 @@ def set_value(self, value):
elif self.type == 'boolean':
self._set_boolean_value(value)
else:
- raise TypeError, 'unknown type (%s)' % self.type
+ raise TypeError('unknown type (%s)' % self.type)
def get_value(self):
if self._value == None:
@@ -188,7 +188,7 @@ def get_value(self):
self._set_boolean_value(self._value)
return self._value
else:
- raise TypeError, 'unknown type (%s)' % self.type
+ raise TypeError('unknown type (%s)' % self.type)
value = property(get_value, set_value, 'The value of the parameter')
View
2  boto/roboto/awsqueryrequest.py
@@ -223,7 +223,7 @@ def process_filters(self):
filter_names = [f['name'] for f in self.Filters]
unknown_filters = [f for f in filters if f not in filter_names]
if unknown_filters:
- raise FilterError, 'Unknown filters: %s' % unknown_filters
+ raise FilterError('Unknown filters: %s' % unknown_filters)
for i, filter in enumerate(self.Filters):
name = filter['name']
if name in filters:
View
8 boto/sdb/db/key.py
@@ -23,7 +23,7 @@ class Key(object):
@classmethod
def from_path(cls, *args, **kwds):
- raise NotImplementedError, "Paths are not currently supported"
+ raise NotImplementedError("Paths are not currently supported")
def __init__(self, encoded=None, obj=None):
self.name = None
@@ -35,7 +35,7 @@ def __init__(self, encoded=None, obj=None):
self.kind = None
def app(self):
- raise NotImplementedError, "Applications are not currently supported"
+ raise NotImplementedError("Applications are not currently supported")
def kind(self):
return self.kind
@@ -44,7 +44,7 @@ def id(self):
return self.id
def name(self):
- raise NotImplementedError, "Key Names are not currently supported"
+ raise NotImplementedError("Key Names are not currently supported")
def id_or_name(self):
return self.id
@@ -53,7 +53,7 @@ def has_id_or_name(self):
return self.id != None
def parent(self):
- raise NotImplementedError, "Key parents are not currently supported"
+ raise NotImplementedError("Key parents are not currently supported")
def __str__(self):
return self.id_or_name()
View
2  boto/sdb/db/manager/__init__.py
@@ -87,5 +87,5 @@ def get_manager(cls):
return XMLManager(cls, db_name, db_user, db_passwd,
db_host, db_port, db_table, sql_dir, enable_ssl)
else:
- raise ValueError, 'Unknown db_type: %s' % db_type
+ raise ValueError('Unknown db_type: %s' % db_type)
View
8 boto/sdb/db/manager/pgmanager.py
@@ -105,7 +105,7 @@ def decode_reference(self, value):
try:
return self.manager.get_object_from_id(value)
except:
- raise ValueError, 'Unable to convert %s to Object' % value
+ raise ValueError('Unable to convert %s to Object' % value)
class PGManager(object):
@@ -296,9 +296,9 @@ def lookup(self, cls, name, value):
row = self.cursor.fetchone()
return self._object_from_row(row, self.cursor.description)
elif self.cursor.rowcount == 0:
- raise KeyError, 'Object not found'
+ raise KeyError('Object not found')
else:
- raise LookupError, 'Multiple Objects Found'
+ raise LookupError('Multiple Objects Found')
def query(self, cls, filters, limit=None, order_by=None):
parts = []
@@ -333,7 +333,7 @@ def get_property(self, prop, obj, name):
if prop.name == name:
v = self.decode_value(prop, rs[0])
return v
- raise AttributeError, '%s not found' % name
+ raise AttributeError('%s not found' % name)
def set_property(self, prop, obj, name, value):
pass
View
6 boto/sdb/db/manager/sdbmanager.py
@@ -101,7 +101,7 @@ def encode_map(self, prop, value):
if value == None:
return None
if not isinstance(value, dict):
- raise ValueError, 'Expected a dict value, got %s' % type(value)
+ raise ValueError('Expected a dict value, got %s' % type(value))
new_value = []
for key in value:
item_type = getattr(prop, "item_type")
@@ -640,7 +640,7 @@ def _get_all_decendents(self, cls):
return decendents
def query_gql(self, query_string, *args, **kwds):
- raise NotImplementedError, "GQL queries not supported in SimpleDB"
+ raise NotImplementedError("GQL queries not supported in SimpleDB")
def save_object(self, obj, expected_value=None):
if not obj.id:
@@ -706,7 +706,7 @@ def get_property(self, prop, obj, name):
value = prop.make_value_from_datastore(value)
setattr(obj, prop.name, value)
return value
- raise AttributeError, '%s not found' % name
+ raise AttributeError('%s not found' % name)
def set_key_value(self, obj, name, value):
self.domain.put_attributes(obj.id, {name : value}, replace=True)
View
2  boto/sdb/db/manager/xmlmanager.py
@@ -395,7 +395,7 @@ def _build_query(self, cls, filters, limit, order_by):
return ' intersection '.join(parts)
def query_gql(self, query_string, *args, **kwds):
- raise NotImplementedError, "GQL queries not supported in XML"
+ raise NotImplementedError("GQL queries not supported in XML")
def save_list(self, doc, items, prop_node):
items_node = doc.createElement('items')
View
4 boto/sdb/db/model.py
@@ -86,7 +86,7 @@ def get_by_id(cls, ids=None, parent=None):
@classmethod
def get_by_key_name(cls, key_names, parent=None):
- raise NotImplementedError, "Key Names are not currently supported"
+ raise NotImplementedError("Key Names are not currently supported")
@classmethod
def find(cls, limit=None, next_token=None, **params):
@@ -101,7 +101,7 @@ def all(cls, limit=None, next_token=None):
@classmethod
def get_or_insert(key_name, **kw):
- raise NotImplementedError, "get_or_insert not currently supported"
+ raise NotImplementedError("get_or_insert not currently supported")
@classmethod
def properties(cls, hidden=True):
View
50 boto/sdb/db/property.py
@@ -78,16 +78,16 @@ def default_validator(self, value):
if isinstance(value, basestring) or value == self.default_value():
return
if not isinstance(value, self.data_type):
- raise TypeError, 'Validation Error, %s.%s expecting %s, got %s' % (self.model_class.__name__, self.name, self.data_type, type(value))
+ raise TypeError('Validation Error, %s.%s expecting %s, got %s' % (self.model_class.__name__, self.name, self.data_type, type(value)))
def default_value(self):
return self.default
def validate(self, value):
if self.required and value==None:
- raise ValueError, '%s is a required property' % self.name
+ raise ValueError('%s is a required property' % self.name)
if self.choices and value and not value in self.choices:
- raise ValueError, '%s not a valid choice for %s.%s' % (value, self.model_class.__name__, self.name)
+ raise ValueError('%s not a valid choice for %s.%s' % (value, self.model_class.__name__, self.name))
if self.validator:
self.validator(value)
else:
@@ -113,9 +113,9 @@ def validate_string(value):
return
elif isinstance(value, str) or isinstance(value, unicode):
if len(value) > 1024:
- raise ValueError, 'Length of value greater than maxlength'
+ raise ValueError('Length of value greater than maxlength')
else:
- raise TypeError, 'Expecting String, got %s' % type(value)
+ raise TypeError('Expecting String, got %s' % type(value))
class StringProperty(Property):
@@ -137,9 +137,9 @@ def __init__(self, verbose_name=None, name=None, default='', required=False,
def validate(self, value):
value = super(TextProperty, self).validate(value)
if not isinstance(value, str) and not isinstance(value, unicode):
- raise TypeError, 'Expecting Text, got %s' % type(value)
+ raise TypeError('Expecting Text, got %s' % type(value))
if self.max_length and len(value) > self.max_length:
- raise ValueError, 'Length of value greater than maxlength %s' % self.max_length
+ raise ValueError('Length of value greater than maxlength %s' % self.max_length)
class PasswordProperty(StringProperty):
"""
@@ -227,9 +227,9 @@ def validate(self, value):
value = Property.validate(self, value)
if isinstance(value, self.data_type):
if len(value) > 1024:
- raise ValueError, 'Length of value greater than maxlength'
+ raise ValueError('Length of value greater than maxlength')
else:
- raise TypeError, 'Expecting %s, got %s' % (type(self.data_type), type(value))
+ raise TypeError('Expecting %s, got %s' % (type(self.data_type), type(value)))
class BlobProperty(Property):
data_type = Blob
@@ -266,7 +266,7 @@ def validate(self, value):
match = re.match(self.validate_regex, value)
if match:
return
- raise TypeError, 'Validation Error, expecting %s, got %s' % (self.data_type, type(value))
+ raise TypeError('Validation Error, expecting %s, got %s' % (self.data_type, type(value)))
def __get__(self, obj, objtype):
value = Property.__get__(self, obj, objtype)
@@ -307,9 +307,9 @@ def validate(self, value):
value = int(value)
value = Property.validate(self, value)
if value > self.max:
- raise ValueError, 'Maximum value is %d' % self.max
+ raise ValueError('Maximum value is %d' % self.max)
if value < self.min:
- raise ValueError, 'Minimum value is %d' % self.min
+ raise ValueError('Minimum value is %d' % self.min)
return value
def empty(self, value):
@@ -337,9 +337,9 @@ def validate(self, value):
min = -9223372036854775808
max = 9223372036854775807
if value > max:
- raise ValueError, 'Maximum value is %d' % max
+ raise ValueError('Maximum value is %d' % max)
if value < min:
- raise ValueError, 'Minimum value is %d' % min
+ raise ValueError('Minimum value is %d' % min)
return value
def empty(self, value):
@@ -429,7 +429,7 @@ def validate(self, value):
if value == None:
return
if not isinstance(value, self.data_type):
- raise TypeError, 'Validation Error, expecting %s, got %s' % (self.data_type, type(value))
+ raise TypeError('Validation Error, expecting %s, got %s' % (self.data_type, type(value)))
def get_value_for_datastore(self, model_instance):
if self.auto_now:
@@ -456,7 +456,7 @@ def validate(self, value):
if value is None:
return
if not isinstance(value, self.data_type):
- raise TypeError, 'Validation Error, expecting %s, got %s' % (self.data_type, type(value))
+ raise TypeError('Validation Error, expecting %s, got %s' % (self.data_type, type(value)))
class ReferenceProperty(Property):
@@ -487,7 +487,7 @@ def __set__(self, obj, value):
"""Don't allow this object to be associated to itself
This causes bad things to happen"""
if value != None and (obj.id == value or (hasattr(value, "id") and obj.id == value.id)):
- raise ValueError, "Can not associate an object with itself!"
+ raise ValueError("Can not associate an object with itself!")
return super(ReferenceProperty, self).__set__(obj,value)
def __property_config__(self, model_class, property_name):
@@ -495,7 +495,7 @@ def __property_config__(self, model_class, property_name):
if self.collection_name is None:
self.collection_name = '%s_%s_set' % (model_class.__name__.lower(), self.name)
if hasattr(self.reference_class, self.collection_name):
- raise ValueError, 'duplicate property: %s' % self.collection_name
+ raise ValueError('duplicate property: %s' % self.collection_name)
setattr(self.reference_class, self.collection_name,
_ReverseReferenceProperty(model_class, property_name, self.collection_name))
@@ -511,15 +511,15 @@ def check_instance(self, value):
cls_lineage = self.reference_class.get_lineage()
if obj_lineage.startswith(cls_lineage):
return
- raise TypeError, '%s not instance of %s' % (obj_lineage, cls_lineage)
+ raise TypeError('%s not instance of %s' % (obj_lineage, cls_lineage))
except:
- raise ValueError, '%s is not a Model' % value
+ raise ValueError('%s is not a Model' % value)
def validate(self, value):
if self.validator:
self.validator(value)
if self.required and value==None:
- raise ValueError, '%s is a required property' % self.name
+ raise ValueError('%s is a required property' % self.name)
if value == self.default_value():
return
if not isinstance(value, str) and not isinstance(value, unicode):
@@ -552,7 +552,7 @@ def __get__(self, model_instance, model_class):
def __set__(self, model_instance, value):
"""Not possible to set a new collection."""
- raise ValueError, 'Virtual property is read-only'
+ raise ValueError('Virtual property is read-only')
class CalculatedProperty(Property):
@@ -619,7 +619,7 @@ def validate(self, value):
for item in value:
if not isinstance(item, item_type):
if item_type == (int, long):
- raise ValueError, 'Items in the %s list must all be integers.' % self.name
+ raise ValueError('Items in the %s list must all be integers.' % self.name)
else:
raise ValueError('Items in the %s list must all be %s instances' %
(self.name, self.item_type.__name__))
@@ -661,7 +661,7 @@ def validate(self, value):
value = super(MapProperty, self).validate(value)
if value is not None:
if not isinstance(value, dict):
- raise ValueError, 'Value must of type dict'
+ raise ValueError('Value must of type dict')
if self.item_type in (int, long):
item_type = (int, long)
@@ -673,7 +673,7 @@ def validate(self, value):
for key in value:
if not isinstance(value[key], item_type):
if item_type == (int, long):
- raise ValueError, 'Values in the %s Map must all be integers.' % self.name
+ raise ValueError('Values in the %s Map must all be integers.' % self.name)
else:
raise ValueError('Values in the %s Map must all be %s instances' %
(self.name, self.item_type.__name__))
View
2  boto/sdb/db/sequence.py
@@ -171,7 +171,7 @@ def set(self, val):
self.timestamp = new_val['timestamp']
except SDBResponseError, e:
if e.status == 409:
- raise ValueError, "Sequence out of sync"
+ raise ValueError("Sequence out of sync")
else:
raise
Please sign in to comment.
Something went wrong with that request. Please try again.