fix raise Exception

This commit is contained in:
J. Borovec 2020-03-12 14:53:36 +01:00
parent 6718706c65
commit 346c2cb9b4
4 changed files with 10 additions and 12 deletions

View File

@ -1032,15 +1032,15 @@ class FAHControl(SingleAppServer):
# Validate passkey # Validate passkey
if not self.passkey_validator.is_good(): if not self.passkey_validator.is_good():
raise Exception, 'Passkey is invalid' raise Exception('Passkey is invalid')
# Validate password # Validate password
if not self.password_validator.is_good(): if not self.password_validator.is_good():
raise Exception, 'Client password is invalid' raise Exception('Client password is invalid')
# Validate proxy password # Validate proxy password
if not self.proxy_pass_validator.is_good(): if not self.proxy_pass_validator.is_good():
raise Exception, 'Proxy password is invalid' raise Exception('Proxy password is invalid')
self.deactivate_client() self.deactivate_client()

View File

@ -42,7 +42,7 @@ class SlotConfig:
# Type # Type
if self.description.startswith('cpu'): self.type = 'cpu' if self.description.startswith('cpu'): self.type = 'cpu'
elif self.description.startswith('gpu'): self.type = 'gpu' elif self.description.startswith('gpu'): self.type = 'gpu'
else: raise Exception, 'Invalid slot type "%s"' % description else: raise Exception('Invalid slot type "%s"' % description)
def add_to_ui(self, app): def add_to_ui(self, app):
@ -94,7 +94,7 @@ class SlotConfig:
# Type # Type
if self.type == 'cpu': app.slot_type_cpu.set_active(True) if self.type == 'cpu': app.slot_type_cpu.set_active(True)
elif self.type == 'gpu': app.slot_type_gpu.set_active(True) elif self.type == 'gpu': app.slot_type_gpu.set_active(True)
else: raise Exception, 'Invalid slot type "%s"' % self.type else: raise Exception('Invalid slot type "%s"' % self.type)
used.add('gpu') used.add('gpu')
# SMP # SMP

View File

@ -52,7 +52,7 @@ class Database:
for table in self.tables: for table in self.tables:
if table.name == name: return table if table.name == name: return table
raise Exception, 'Table "%s" not found' % name raise Exception('Table "%s" not found' % name)
def get_version(self): def get_version(self):
@ -152,9 +152,8 @@ class Database:
def validate(self): def validate(self):
current = self.get_current_version() current = self.get_current_version()
if self.get_version() < current: if self.get_version() < current:
raise Exception, \ raise Exception('Configuration database "%s" version %d is newer than is supported %d'
('Configuration database "%s" version %d is newer than is ' % (self.filename, current, self.get_version()))
'supported %d') % (self.filename, current, self.get_version())
elif self.get_version() != current: elif self.get_version() != current:
# Create or upgrade DB # Create or upgrade DB

View File

@ -57,8 +57,8 @@ class Table:
if len(cols) != len(kwargs): if len(cols) != len(kwargs):
col_names = set(map(Column.get_name, cols)) col_names = set(map(Column.get_name, cols))
missing = filter(lambda kw: not kw in col_names, kwargs.keys()) missing = filter(lambda kw: not kw in col_names, kwargs.keys())
raise Exception, 'Table %s does not have column(s) %s' % ( raise Exception('Table %s does not have column(s) %s'
self.name, ', '.join(missing)) % (self.name, ', '.join(missing)))
sql = 'REPLACE INTO "%s" ("%s") VALUES (%s)' % ( sql = 'REPLACE INTO "%s" ("%s") VALUES (%s)' % (
self.name, '","'.join(map(Column.get_name, cols)), self.name, '","'.join(map(Column.get_name, cols)),
@ -66,7 +66,6 @@ class Table:
db.execute(sql).close() db.execute(sql).close()
def select(self, db, cols = None, **kwargs): def select(self, db, cols = None, **kwargs):
if cols is None: if cols is None:
cols = '"' + '","'.join(map(str, self.cols)) + '"' cols = '"' + '","'.join(map(str, self.cols)) + '"'