Merge "Fix use the fact that empty sequences are false"
This commit is contained in:
commit
205909a048
@ -1372,7 +1372,7 @@ class AlarmController(rest.RestController):
|
||||
auth_project = acl.get_limited_to_project(pecan.request.headers)
|
||||
alarms = list(self.conn.get_alarms(alarm_id=self._id,
|
||||
project=auth_project))
|
||||
if len(alarms) < 1:
|
||||
if not alarms:
|
||||
raise EntityNotFound(_('Alarm'), self._id)
|
||||
return alarms[0]
|
||||
|
||||
@ -1574,7 +1574,7 @@ class AlarmsController(rest.RestController):
|
||||
# make sure alarms are unique by name per project.
|
||||
alarms = list(conn.get_alarms(name=data.name,
|
||||
project=data.project_id))
|
||||
if len(alarms) > 0:
|
||||
if alarms:
|
||||
raise ClientSideError(_("Alarm with that name exists"))
|
||||
|
||||
try:
|
||||
@ -1805,7 +1805,7 @@ class EventsController(rest.RestController):
|
||||
"""
|
||||
event_filter = storage.EventFilter(message_id=message_id)
|
||||
events = pecan.request.storage_conn.get_events(event_filter)
|
||||
if len(events) == 0:
|
||||
if not events:
|
||||
raise EntityNotFound(_("Event"), message_id)
|
||||
|
||||
if len(events) > 1:
|
||||
|
@ -379,7 +379,7 @@ class Connection(base.Connection):
|
||||
LOG.debug(_("Query Resource table: %s") % q)
|
||||
|
||||
# handle metaquery
|
||||
if len(metaquery) > 0:
|
||||
if metaquery:
|
||||
meta_q = []
|
||||
for k, v in metaquery.iteritems():
|
||||
meta_q.append(
|
||||
@ -445,7 +445,7 @@ class Connection(base.Connection):
|
||||
# TODO(jd) implements using HBase capabilities
|
||||
if limit == 0:
|
||||
break
|
||||
if len(metaquery) > 0:
|
||||
if metaquery:
|
||||
for k, v in metaquery.iteritems():
|
||||
message = json.loads(meter['f:message'])
|
||||
metadata = message['resource_metadata']
|
||||
@ -549,7 +549,7 @@ class Connection(base.Connection):
|
||||
start_time, ts) / period) * period
|
||||
period_start = start_time + datetime.timedelta(0, offset)
|
||||
|
||||
if not len(results) or not results[-1].period_start == \
|
||||
if not results or not results[-1].period_start == \
|
||||
period_start:
|
||||
if period:
|
||||
period_end = period_start + datetime.timedelta(
|
||||
@ -770,7 +770,7 @@ def make_query(user=None, project=None, meter=None,
|
||||
rts_end)
|
||||
|
||||
sample_filter = None
|
||||
if len(q):
|
||||
if q:
|
||||
sample_filter = " AND ".join(q)
|
||||
|
||||
if query_only:
|
||||
|
@ -50,7 +50,7 @@ def db_version(engine):
|
||||
meta = sqlalchemy.MetaData()
|
||||
meta.reflect(bind=engine)
|
||||
tables = meta.tables
|
||||
if len(tables) == 0:
|
||||
if not tables:
|
||||
db_version_control(engine, 0)
|
||||
return versioning_api.db_version(engine, repository)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user