Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions tools/migration/migrator_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ def __init__(self, config_data, debug=False, dry_run=False, step_by_step=False):
def set_prefix_transformations(self, config_data):
""" Sets the path prefix transformations for the instances. """
key = "path_prefix_transformation"
if key in config_data and all(x in config_data[key] for x in ["from", "to"]):
regex = re.compile("^" + config_data[key]["from"])
self.path_transform = lambda x: regex.sub(config_data[key]["to"], x)
if key in config_data['new_instance'] and all(x in config_data['new_instance'][key] for x in ["from", "to"]):
regex = re.compile("^" + config_data['new_instance'][key]["from"])
self.path_transform = lambda x: regex.sub(config_data['new_instance'][key]["to"], x)
else:
self.path_transform = lambda x: x

Expand All @@ -94,7 +94,7 @@ def check_project(self, client):

def create_clients(self, config_data):
""" Reads the given config defined by its path and creates the two teamscale clients from it.
One old instance (migrating from) and a new onoe (migrating to).
One old instance (migrating from) and a new one (migrating to).
"""
try:
return self.get_client(config_data["old_instance"]), self.get_client(config_data["new_instance"])
Expand Down Expand Up @@ -151,7 +151,7 @@ def get(self, client, service, path_suffix="", parameters=None, use_cache=True):
self.logger.debug("Service Call: {}".format((url, parameters)))
response = client.get(url, parameters).json()
except ServiceError as e:
self.logger.exception("Fetching data from %s failed (%s)" % (url, e.response.status_code))
self.logger.exception("Fetching data from %s failed (%s)" % (url, e))
self.cache_request((url, parameters), response, use_cache)
return response

Expand Down Expand Up @@ -216,9 +216,8 @@ def get_finding_by_id(self, client, finding_id):
try:
return self.get(client, "findings-by-id", path_suffix=finding_id)
except ServiceError as e:
if e.response.status_code == 400:
self.logger.debug("Finding with id %s not found. Skipping." % finding_id)
return None
self.logger.debug("Finding with id %s not found. Skipping." % finding_id)
return None

def get_findings_url(self, findings_id, client=None):
""" Creates a url link to the finding with the given id on the given Teamscale """
Expand Down