mirror of
https://github.com/thegeeklab/docker-tidy.git
synced 2024-11-24 13:10:40 +00:00
fix linting
This commit is contained in:
parent
1052c8b2ed
commit
2fa9280aa6
@ -44,8 +44,11 @@ class AutoStop:
|
||||
prefix and matcher(name) and self._has_been_running_since(container, max_run_time)
|
||||
) or (not prefix and self._has_been_running_since(container, max_run_time)):
|
||||
self.logger.info(
|
||||
"Stopping container %s %s: running since %s" %
|
||||
(container["Id"][:16], name, container["State"]["StartedAt"])
|
||||
"Stopping container {id} {name}: running since {started}".format(
|
||||
id=container["Id"][:16],
|
||||
name=name,
|
||||
started=container["State"]["StartedAt"]
|
||||
)
|
||||
)
|
||||
|
||||
if not dry_run:
|
||||
@ -55,9 +58,9 @@ class AutoStop:
|
||||
try:
|
||||
client.stop(cid)
|
||||
except requests.exceptions.Timeout as e:
|
||||
self.logger.warn("Failed to stop container %s: %s" % (cid, e))
|
||||
except docker.errors.APIError as ae:
|
||||
self.logger.warn("Error stopping %s: %s" % (cid, ae))
|
||||
self.logger.warn("Failed to stop container {id}: {msg}".format(id=cid, msg=str(e)))
|
||||
except docker.errors.APIError as e:
|
||||
self.logger.warn("Error stopping {id}: {msg}".format(id=cid, msg=str(e)))
|
||||
|
||||
def _build_container_matcher(self, prefixes):
|
||||
|
||||
|
@ -6,7 +6,7 @@ class TidyError(Exception):
|
||||
"""Generic exception class for docker-tidy."""
|
||||
|
||||
def __init__(self, msg, original_exception=""):
|
||||
super(TidyError, self).__init__(msg + ("\n%s" % original_exception))
|
||||
super(TidyError, self).__init__("{msg}\n{org}".format(msg=msg, org=original_exception))
|
||||
self.original_exception = original_exception
|
||||
|
||||
|
||||
|
@ -181,7 +181,7 @@ class GarbageCollector:
|
||||
image_tags = image_summary.get("RepoTags")
|
||||
if self._no_image_tags(image_tags):
|
||||
# The repr of the image Id used by client.containers()
|
||||
return set(["%s:latest" % image_summary["Id"][:12]])
|
||||
return set(["{id}:latest".format(id=image_summary["Id"][:12])])
|
||||
return set(image_tags)
|
||||
|
||||
def image_not_in_use(image_summary):
|
||||
@ -210,7 +210,9 @@ class GarbageCollector:
|
||||
if not image or not self._is_image_old(image, min_date):
|
||||
return
|
||||
|
||||
self.logger.info("Removing image %s" % self._format_image(image, image_summary))
|
||||
self.logger.info(
|
||||
"Removing image {name}".format(name=self._format_image(image, image_summary))
|
||||
)
|
||||
if config["dry_run"]:
|
||||
return
|
||||
|
||||
@ -230,7 +232,7 @@ class GarbageCollector:
|
||||
if not volume:
|
||||
return
|
||||
|
||||
self.logger.info("Removing volume %s" % volume["Name"])
|
||||
self.logger.info("Removing volume {name}".format(name=volume["Name"]))
|
||||
if config["dry_run"]:
|
||||
return
|
||||
|
||||
@ -249,11 +251,19 @@ class GarbageCollector:
|
||||
try:
|
||||
return func(**kwargs)
|
||||
except requests.exceptions.Timeout as e:
|
||||
params = ",".join("%s=%s" % item for item in kwargs.items())
|
||||
self.logger.warn("Failed to call %s %s %s" % (func.__name__, params, e))
|
||||
except docker.errors.APIError as ae:
|
||||
params = ",".join("%s=%s" % item for item in kwargs.items())
|
||||
self.logger.warn("Error calling %s %s %s" % (func.__name__, params, ae))
|
||||
params = ",".join("%s=%s" % item for item in kwargs.items()) # noqa
|
||||
self.logger.warn(
|
||||
"Failed to call {name} {params} {msg}".format(
|
||||
name=func.__name__, params=params, msg=str(e)
|
||||
)
|
||||
)
|
||||
except docker.errors.APIError as e:
|
||||
params = ",".join("%s=%s" % item for item in kwargs.items()) # noqa
|
||||
self.logger.warn(
|
||||
"Error calling {name} {params} {msg}".format(
|
||||
name=func.__name__, params=params, msg=str(e)
|
||||
)
|
||||
)
|
||||
|
||||
def _format_image(self, image, image_summary):
|
||||
|
||||
@ -263,7 +273,7 @@ class GarbageCollector:
|
||||
return ""
|
||||
return ", ".join(tags)
|
||||
|
||||
return "%s %s" % (image["Id"][:16], get_tags())
|
||||
return "{id} {tags}".format(id=image["Id"][:16], tags=get_tags())
|
||||
|
||||
def _build_exclude_set(self):
|
||||
config = self.config.config
|
||||
|
Loading…
Reference in New Issue
Block a user