From: Frank Brehm Date: Thu, 20 Apr 2017 09:51:56 +0000 (+0200) Subject: Applying flake8 to pp_lib/homes_admin.py X-Git-Tag: 0.1.2~187 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=ff45b6cf7afd24d587083f34d99a0f15f865d607;p=pixelpark%2Fadmin-tools.git Applying flake8 to pp_lib/homes_admin.py --- diff --git a/pp_lib/homes_admin.py b/pp_lib/homes_admin.py index 145a664..38adf0d 100644 --- a/pp_lib/homes_admin.py +++ b/pp_lib/homes_admin.py @@ -9,30 +9,22 @@ from __future__ import absolute_import # Standard modules -import sys import os import logging import logging.config import re -import traceback -import textwrap import pwd -import copy import glob # Third party modules import six # 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 +from .common import pp from .cfg_app import PpCfgAppError, PpConfigApplication -__version__ = '0.1.2' +__version__ = '0.1.3' LOG = logging.getLogger(__name__) @@ -59,8 +51,8 @@ class PpHomesAdminApp(PpConfigApplication): # ------------------------------------------------------------------------- def __init__( - self, appname=None, description=None, - cfg_stems='homes-admin', version=__version__): + self, appname=None, description=None, + cfg_stems='homes-admin', version=__version__): self.default_mail_recipients = [ 'admin.berlin@pixelpark.com' @@ -90,7 +82,8 @@ class PpHomesAdminApp(PpConfigApplication): homes_group.add_argument( '-R', '--chroot-dir', metavar='DIR', dest='chroot_homedir', - help=("Directory, where the {h!r} share is mounted from the " + help=( + "Directory, where the {h!r} share is mounted from the " "NFS server. Maybe '/', default: {d!r}.").format( h=self.default_home_root, d=self.default_chroot_homedir) ) @@ -98,14 +91,16 @@ class PpHomesAdminApp(PpConfigApplication): homes_group.add_argument( '-H', '--homes', metavar='DIR', dest='home_root', - help=("The shared directory on the NFS server for all home directories. " + help=( + "The shared directory on the NFS server for all home directories. " "Default: {!r}.").format(self.default_home_root) ) homes_group.add_argument( '-E', '--exclude-file', metavar='FILE', dest='exclude_file', - help=("The file containing all directories underneath {h!r}, which are " + help=( + "The file containing all directories underneath {h!r}, which are " "excluded from all operations. Default: {f!r}.").format( h=self.default_home_root, f=self.default_exclude_file) ) @@ -125,7 +120,7 @@ class PpHomesAdminApp(PpConfigApplication): section = self.cfg[section_name] if section_name.lower() not in ( - 'test-home', 'test_home', 'testhome', 'homes', 'admin') : + 'test-home', 'test_home', 'testhome', 'homes', 'admin'): continue if self.verbose > 2: @@ -166,6 +161,14 @@ class PpHomesAdminApp(PpConfigApplication): raise PpHomesAdminError(msg) self.exclude_file = v + self._perform_home_cmdline_opts() + + self.home_root_rel = os.path.relpath(self.home_root_abs, os.sep) + self.home_root_real = os.path.join(self.chroot_homedir, self.home_root_rel) + + # ------------------------------------------------------------------------- + def _perform_home_cmdline_opts(self): + if hasattr(self.args, 'chroot_homedir') and self.args.chroot_homedir: v = self.args.chroot_homedir if not os.path.isabs(v): @@ -193,9 +196,6 @@ class PpHomesAdminApp(PpConfigApplication): raise PpHomesAdminError(msg) self.exclude_file = v - self.home_root_rel = os.path.relpath(self.home_root_abs, os.sep) - self.home_root_real = os.path.join(self.chroot_homedir, self.home_root_rel) - # ------------------------------------------------------------------------- def read_exclude_dirs(self):