From: Frank Brehm Date: Thu, 20 Apr 2017 12:26:38 +0000 (+0200) Subject: Applying flake8 to pp_lib/quota_check.py X-Git-Tag: 0.1.2~182 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=f18dcdc7797d7fac1393ca2dec5bc710fd9ba8f7;p=pixelpark%2Fadmin-tools.git Applying flake8 to pp_lib/quota_check.py --- diff --git a/pp_lib/quota_check.py b/pp_lib/quota_check.py index 7749f9e..d01d2ed 100644 --- a/pp_lib/quota_check.py +++ b/pp_lib/quota_check.py @@ -9,16 +9,13 @@ from __future__ import absolute_import # Standard modules -import sys import os import datetime import logging import logging.config import re -import traceback import textwrap import pwd -import copy import glob import stat import pipes @@ -34,17 +31,11 @@ import six import yaml # Own modules -from .global_version import __version__ as __global_version__ - -from .errors import FunctionNotImplementedError, PpAppError - -from .common import pp, terminal_can_colors, to_bytes, to_bool, to_str - -from .cfg_app import PpCfgAppError +from .common import pp, to_str from .homes_admin import PpHomesAdminError, PpHomesAdminApp -__version__ = '0.6.1' +__version__ = '0.6.2' LOG = logging.getLogger(__name__) UTC = datetime.timezone.utc @@ -136,7 +127,8 @@ class PpQuotaCheckApp(PpHomesAdminApp): self.arg_parser.add_argument( '--status-file', metavar='FILE', dest='status_file', - help=("The YAML file containing the statistics of the current week " + help=( + "The YAML file containing the statistics of the current week " "(default: {!r}).").format(self.statusfile) ) @@ -159,7 +151,7 @@ class PpQuotaCheckApp(PpHomesAdminApp): if self.verbose > 3: LOG.debug("Checking config section {!r} ...".format(section_name)) - if section_name.lower() not in ('quota-check', 'quota_check', 'quotacheck') : + if section_name.lower() not in ('quota-check', 'quota_check', 'quotacheck'): continue section = self.cfg[section_name] @@ -172,7 +164,7 @@ class PpQuotaCheckApp(PpHomesAdminApp): quota = self.quota_kb / 1024 try: quota = int(v) - except (ValueError, TypeError) as e: + except (ValueError, TypeError): msg = "Found invalid quota MB {!r} in configuration.".format(v) LOG.error(msg) else: @@ -187,7 +179,7 @@ class PpQuotaCheckApp(PpHomesAdminApp): quota = self.quota_kb try: quota = int(v) - except (ValueError, TypeError) as e: + except (ValueError, TypeError): msg = "Found invalid quota KB {!r} in configuration.".format(v) LOG.error(msg) else: @@ -409,7 +401,6 @@ class PpQuotaCheckApp(PpHomesAdminApp): LOG.info("Reading all necessary data from 'getent passwd' ...") - upper_dir = os.pardir + os.sep entries = pwd.getpwall() for entry in entries: @@ -598,9 +589,9 @@ class PpQuotaCheckApp(PpHomesAdminApp): else: - body += ("No home directory found with a recursive size " - "greater or equal than {:.f} MB.").format( - self.quota_kb / 1024) + body += ( + "No home directory found with a recursive size " + "greater or equal than {:.f} MB.").format(self.quota_kb / 1024) body += "\n\nCheers\n\n" + self.mail_from + '\n' @@ -616,7 +607,7 @@ class PpQuotaCheckApp(PpHomesAdminApp): total_dirs = {} for check_date in self.status_data['checks'].keys(): check = self.status_data['checks'][check_date] - if not 'data' in check or not check['data'].keys(): + if 'data' not in check or not check['data'].keys(): continue # Consolidating data ... for home in check['data'].keys():