From: Frank Brehm Date: Tue, 6 Feb 2018 10:37:52 +0000 (+0100) Subject: Applying flake8 rules to pp_lib/quota_check.py X-Git-Tag: 0.1.2~6^2~45 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=66401f01bfed6d29c7d027dde2d3230a9376a5ea;p=pixelpark%2Fadmin-tools.git Applying flake8 rules to pp_lib/quota_check.py --- diff --git a/pp_lib/quota_check.py b/pp_lib/quota_check.py index 0726203..4db1ee8 100644 --- a/pp_lib/quota_check.py +++ b/pp_lib/quota_check.py @@ -23,6 +23,7 @@ import gzip import shutil import time import locale +import sys from subprocess import Popen, PIPE @@ -35,7 +36,7 @@ from .common import pp, to_str from .homes_admin import PpHomesAdminError, PpHomesAdminApp -__version__ = '0.6.2' +__version__ = '0.6.3' LOG = logging.getLogger(__name__) ZERO = datetime.timedelta(0) @@ -479,9 +480,7 @@ class PpQuotaCheckApp(PpHomesAdminApp): return result # ------------------------------------------------------------------------- - def check_home_utilization(self): - - LOG.info("Checking utilization of home directories ...") + def _silly_open_homedirs(self): # Senseless opening of all user home directories to activate automounter for user_name in self.passwd_data: @@ -491,7 +490,8 @@ class PpQuotaCheckApp(PpHomesAdminApp): continue if not pwd_home_dir.startswith(self.home_root_abs): if self.verbose > 2: - LOG.debug("Home dir {!r} is not below {!r}.".format(pwd_home_dir, self.home_root_abs)) + LOG.debug("Home dir {!r} is not below {!r}.".format( + pwd_home_dir, self.home_root_abs)) continue abs_home_dir = os.path.join(self.chroot_homedir, os.path.relpath(pwd_home_dir, os.sep)) LOG.debug("Trying to open {!r} ...".format(abs_home_dir)) @@ -499,9 +499,16 @@ class PpQuotaCheckApp(PpHomesAdminApp): os.listdir(abs_home_dir) if self.verbose > 2: LOG.debug("Found home directory {!r} ...".format(abs_home_dir)) - except OSError as e: + except OSError: LOG.warn("Directory {!r} does not exists.".format(abs_home_dir)) + # ------------------------------------------------------------------------- + def check_home_utilization(self): + + LOG.info("Checking utilization of home directories ...") + + self._silly_open_homedirs() + glob_pattern = os.path.join(self.home_root_real, '*') all_home_entries = glob.glob(glob_pattern)