X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Fwim%2Fpersistence.py;h=74f7dc61ad4ff697e76e6d257afd2d47d237c0e4;hb=1d55a23c9cd32f17bb7a6f21e5b6c2b476c5804f;hp=2e72640b6dc8f9c9107f61ae4702e8e7c68118c4;hpb=dfed511cd627748046d90894f8600331413b1cd3;p=osm%2FRO.git diff --git a/osm_ro/wim/persistence.py b/osm_ro/wim/persistence.py index 2e72640b..74f7dc61 100644 --- a/osm_ro/wim/persistence.py +++ b/osm_ro/wim/persistence.py @@ -45,7 +45,7 @@ from hashlib import sha1 from itertools import groupby from operator import itemgetter from sys import exc_info -from time import time +# from time import time from uuid import uuid1 as generate_uuid from six import reraise @@ -642,8 +642,9 @@ class WimPersistence(object): if num_changes is None: raise UnexpectedDatabaseError( - 'Impossible to update wim_port_mappings %s:\n%s\n', - id, _serialize(properties)) + 'Impossible to update wim_port_mappings {}:\n{}\n'.format( + id, _serialize(properties)) + ) return num_changes @@ -681,8 +682,7 @@ class WimPersistence(object): 'LIMIT {:d},{:d}').format( self.safe_str(wim_account_id), ','.join(type_options), - group_offset, group_limit - ) + group_offset, group_limit) join = 'vim_wim_actions NATURAL JOIN ({}) AS items'.format(items) db_results = self.db.get_rows( @@ -697,7 +697,7 @@ class WimPersistence(object): 'task_index': task_index} try: action = self.query_one('vim_wim_actions', WHERE=condition) - except: + except Exception: actions = self.query('vim_wim_actions', WHERE=condition) self.logger.error('More then one action found:\n%s', json.dumps(actions, indent=4)) @@ -710,8 +710,7 @@ class WimPersistence(object): updates = preprocess_record( merge_dicts(action, properties, extra=extra)) - num_changes = self.db.update_rows('vim_wim_actions', - UPDATE=updates, WHERE=condition) + num_changes = self.db.update_rows('vim_wim_actions', UPDATE=updates, WHERE=condition) if num_changes is None: raise UnexpectedDatabaseError( @@ -782,8 +781,7 @@ class WimPersistence(object): if not changes: return 0 - return self.db.update_rows('instance_actions', - WHERE={'uuid': uuid}, UPDATE=changes) + return self.db.update_rows('instance_actions', WHERE={'uuid': uuid}, UPDATE=changes) def get_only_vm_with_external_net(self, instance_net_id, **kwargs): """Return an instance VM if that is the only VM connected to an