Permalink
Browse files

Use modern exception construction syntax

  • Loading branch information...
1 parent 399a41d commit 5d84b33e15ce30445705cf5ba34b36b09733160f @gholms gholms committed with garnaat Mar 11, 2012
View
@@ -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
@@ -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
@@ -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
@@ -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')
@@ -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
@@ -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()
@@ -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)
@@ -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
@@ -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)
@@ -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
@@ -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):
Oops, something went wrong.

0 comments on commit 5d84b33

Please sign in to comment.