Skip to content

Commit

Permalink
pep8: fix coriolis/db
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristi1324 committed Oct 5, 2023
1 parent ac81463 commit b914955
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 15 deletions.
17 changes: 8 additions & 9 deletions coriolis/db/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def _try_unmap_regions(region_ids):
region_to_unmap, endpoint_id)
delete_endpoint_region_mapping(
context, endpoint_id, region_to_unmap)
except Exception as ex:
except Exception:
LOG.warn(
"Exception occurred while attempting to unmap region '%s' "
"from endpoint '%s'. Ignoring. Error was: %s",
Expand Down Expand Up @@ -228,7 +228,7 @@ def _try_unmap_regions(region_ids):
mapping.endpoint_id = endpoint_id
add_endpoint_region_mapping(context, mapping)
newly_mapped_regions.append(region_id)
except Exception as ex:
except Exception:
LOG.warn(
"Exception occurred while adding region mapping for '%s' to "
"endpoint '%s'. Cleaning up created mappings (%s). Error was: "
Expand All @@ -241,7 +241,7 @@ def _try_unmap_regions(region_ids):
try:
_update_sqlalchemy_object_fields(
endpoint, updateable_fields, updated_values)
except Exception as ex:
except Exception:
LOG.warn(
"Exception occurred while updating fields of endpoint '%s'. "
"Cleaning ""up created mappings (%s). Error was: %s",
Expand Down Expand Up @@ -1044,7 +1044,7 @@ def get_region_mappings_for_endpoint(
models.EndpointRegionMapping.endpoint_id == endpoint_id)
if enabled_regions_only:
q = q.filter(
models.Region.enabled == True)
models.Region.enabled == True) # noqa: E712
return q.all()


Expand Down Expand Up @@ -1110,7 +1110,7 @@ def _try_unmap_regions(region_ids):
region_to_unmap, service_id)
delete_service_region_mapping(
context, service_id, region_to_unmap)
except Exception as ex:
except Exception:
LOG.warn(
"Exception occurred while attempting to unmap region '%s' "
"from service '%s'. Ignoring. Error was: %s",
Expand Down Expand Up @@ -1155,7 +1155,7 @@ def _try_unmap_regions(region_ids):
mapping.service_id = service_id
add_service_region_mapping(context, mapping)
newly_mapped_regions.append(region_id)
except Exception as ex:
except Exception:
LOG.warn(
"Exception occurred while adding region mapping for '%s' to "
"service '%s'. Cleaning up created mappings (%s). Error was: "
Expand All @@ -1168,7 +1168,7 @@ def _try_unmap_regions(region_ids):
try:
_update_sqlalchemy_object_fields(
service, updateable_fields, updated_values)
except Exception as ex:
except Exception:
LOG.warn(
"Exception occurred while updating fields of service '%s'. "
"Cleaning ""up created mappings (%s). Error was: %s",
Expand Down Expand Up @@ -1246,7 +1246,7 @@ def get_region_mappings_for_service(
models.ServiceRegionMapping.service_id == service_id)
if enabled_regions_only:
q = q.filter(
models.Region.enabled == True)
models.Region.enabled == True) # noqa: E712
return q.all()


Expand Down Expand Up @@ -1351,7 +1351,6 @@ def set_minion_machines_allocation_statuses(

@enginefacade.writer
def delete_minion_machine(context, minion_machine_id):
minion_machine = get_minion_machine(context, minion_machine_id)
# TODO(aznashwan): update models to be soft-delete-aware to
# avoid needing to hard-delete here:
count = _soft_delete_aware_query(context, models.MinionMachine).filter_by(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sqlalchemy
from sqlalchemy import types


def upgrade(migrate_engine):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sqlalchemy
from sqlalchemy import types


def upgrade(migrate_engine):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ def upgrade(migrate_engine):
meta = sqlalchemy.MetaData()
meta.bind = migrate_engine

endpoint = sqlalchemy.Table(
'endpoint', meta, autoload=True)
base_transfer_action = sqlalchemy.Table(
'base_transfer_action', meta, autoload=True)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sqlalchemy
from sqlalchemy import types


def upgrade(migrate_engine):
Expand Down
2 changes: 1 addition & 1 deletion coriolis/db/sqlalchemy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def process_result_value(self, value, dialect):
data = None
try:
data = zlib.decompress(value)
except:
except Exception:
data = value
return jsonutils.loads(data)

Expand Down

0 comments on commit b914955

Please sign in to comment.