mirror of
https://github.com/thegeeklab/docker-tidy.git
synced 2024-11-24 21:20:42 +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)
|
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)):
|
) or (not prefix and self._has_been_running_since(container, max_run_time)):
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
"Stopping container %s %s: running since %s" %
|
"Stopping container {id} {name}: running since {started}".format(
|
||||||
(container["Id"][:16], name, container["State"]["StartedAt"])
|
id=container["Id"][:16],
|
||||||
|
name=name,
|
||||||
|
started=container["State"]["StartedAt"]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
@ -55,9 +58,9 @@ class AutoStop:
|
|||||||
try:
|
try:
|
||||||
client.stop(cid)
|
client.stop(cid)
|
||||||
except requests.exceptions.Timeout as e:
|
except requests.exceptions.Timeout as e:
|
||||||
self.logger.warn("Failed to stop container %s: %s" % (cid, e))
|
self.logger.warn("Failed to stop container {id}: {msg}".format(id=cid, msg=str(e)))
|
||||||
except docker.errors.APIError as ae:
|
except docker.errors.APIError as e:
|
||||||
self.logger.warn("Error stopping %s: %s" % (cid, ae))
|
self.logger.warn("Error stopping {id}: {msg}".format(id=cid, msg=str(e)))
|
||||||
|
|
||||||
def _build_container_matcher(self, prefixes):
|
def _build_container_matcher(self, prefixes):
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ class TidyError(Exception):
|
|||||||
"""Generic exception class for docker-tidy."""
|
"""Generic exception class for docker-tidy."""
|
||||||
|
|
||||||
def __init__(self, msg, original_exception=""):
|
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
|
self.original_exception = original_exception
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ class GarbageCollector:
|
|||||||
image_tags = image_summary.get("RepoTags")
|
image_tags = image_summary.get("RepoTags")
|
||||||
if self._no_image_tags(image_tags):
|
if self._no_image_tags(image_tags):
|
||||||
# The repr of the image Id used by client.containers()
|
# 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)
|
return set(image_tags)
|
||||||
|
|
||||||
def image_not_in_use(image_summary):
|
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):
|
if not image or not self._is_image_old(image, min_date):
|
||||||
return
|
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"]:
|
if config["dry_run"]:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -230,7 +232,7 @@ class GarbageCollector:
|
|||||||
if not volume:
|
if not volume:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.logger.info("Removing volume %s" % volume["Name"])
|
self.logger.info("Removing volume {name}".format(name=volume["Name"]))
|
||||||
if config["dry_run"]:
|
if config["dry_run"]:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -249,11 +251,19 @@ class GarbageCollector:
|
|||||||
try:
|
try:
|
||||||
return func(**kwargs)
|
return func(**kwargs)
|
||||||
except requests.exceptions.Timeout as e:
|
except requests.exceptions.Timeout as e:
|
||||||
params = ",".join("%s=%s" % item for item in kwargs.items())
|
params = ",".join("%s=%s" % item for item in kwargs.items()) # noqa
|
||||||
self.logger.warn("Failed to call %s %s %s" % (func.__name__, params, e))
|
self.logger.warn(
|
||||||
except docker.errors.APIError as ae:
|
"Failed to call {name} {params} {msg}".format(
|
||||||
params = ",".join("%s=%s" % item for item in kwargs.items())
|
name=func.__name__, params=params, msg=str(e)
|
||||||
self.logger.warn("Error calling %s %s %s" % (func.__name__, params, ae))
|
)
|
||||||
|
)
|
||||||
|
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):
|
def _format_image(self, image, image_summary):
|
||||||
|
|
||||||
@ -263,7 +273,7 @@ class GarbageCollector:
|
|||||||
return ""
|
return ""
|
||||||
return ", ".join(tags)
|
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):
|
def _build_exclude_set(self):
|
||||||
config = self.config.config
|
config = self.config.config
|
||||||
|
2
setup.py
2
setup.py
@ -81,7 +81,7 @@ setup(
|
|||||||
"jsonschema==3.2.0",
|
"jsonschema==3.2.0",
|
||||||
"marshmallow==3.5.1",
|
"marshmallow==3.5.1",
|
||||||
"nested-lookup==0.2.21",
|
"nested-lookup==0.2.21",
|
||||||
"pathspec==0.7.0",
|
"pathspec==0.8.0",
|
||||||
"pyrsistent==0.16.0",
|
"pyrsistent==0.16.0",
|
||||||
"python-dateutil==2.8.1",
|
"python-dateutil==2.8.1",
|
||||||
"python-dotenv==0.12.0",
|
"python-dotenv==0.12.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user