]> Frank Brehm's Git Trees - pixelpark/admin-tools.git/commitdiff
Applying flake8 to pp_lib/quota_check.py
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 20 Apr 2017 12:26:38 +0000 (14:26 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 20 Apr 2017 12:26:38 +0000 (14:26 +0200)
pp_lib/quota_check.py

index 7749f9e22e7ee62a476cfbcaa19744cd84e75c03..d01d2edc96d9f2cbed478dca11064eb546ae91c8 100644 (file)
@@ -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():