from .obj import PpBaseObjectError, PpBaseObject
-__version__ = '0.3.1'
+__version__ = '0.3.2'
LOG = logging.getLogger(__name__)
"""
self._quiet = False
+ self._force = False
+ self._simulate = False
self.env = {}
"""
def quiet(self, value):
self._quiet = bool(value)
+ # -----------------------------------------------------------
+ @property
+ def force(self):
+ """Forced execution of the application."""
+ return self._force
+
+ @force.setter
+ def force(self, value):
+ self._force = bool(value)
+
+ # -----------------------------------------------------------
+ @property
+ def simulate(self):
+ """Simulation mode, nothing is really done."""
+ return self._simulate
+
+ @simulate.setter
+ def simulate(self, value):
+ self._simulate = bool(value)
+
+ # -----------------------------------------------------------
+ @property
+ def show_force_opt(self):
+ """Flag, whether the command line option '--force' should be shown."""
+ return getattr(self, '_show_force_opt', False)
+
+ @show_force_opt.setter
+ def show_force_opt(self, value):
+ self._show_force_opt = bool(value)
+
+ # -----------------------------------------------------------
+ @property
+ def show_simulate_opt(self):
+ """Flag, whether the command line option '--simulate' should be shown."""
+ return getattr(self, '_show_simulate_opt', False)
+
+ @show_simulate_opt.setter
+ def show_simulate_opt(self, value):
+ self._show_simulate_opt = bool(value)
+
# -------------------------------------------------------------------------
def exit(self, retval=-1, msg=None, trace=False):
"""
res['exit_value'] = self.exit_value
res['usage'] = self.usage
res['quiet'] = self.quiet
+ res['force'] = self.force
+ res['simulate'] = self.simulate
res['description'] = self.description
res['argparse_epilog'] = self.argparse_epilog
res['argparse_prefix_chars'] = self.argparse_prefix_chars
"""
- if self.verbose > 1:
- LOG.info("executing pre_run() ...")
+ if self.simulate:
+ LOG.warn("Simulation mode - nothing is really done.")
# -------------------------------------------------------------------------
def _run(self):
help='Silent execution, only warnings and errors are emitted.',
)
+ if self.show_force_opt:
+ general_group.add_argument(
+ "-f", "--force",
+ action="store_true", dest="force",
+ help="Forced execution of this application",
+ )
+
+ if self.show_simulate_opt:
+ general_group.add_argument(
+ "-s", "--simulate",
+ action="store_true", dest="simulate",
+ help="Simulation af all actions, nothing is really done.",
+ )
+
general_group.add_argument(
"-h", "--help",
action='help',
else:
self._terminal_has_colors = self.terminal_can_color()
+ if getattr(self.args, 'force', False):
+ self.force = True
+
+ if getattr(self.args, 'simulate', False):
+ self.simulate = True
+
# -------------------------------------------------------------------------
def perform_arg_parser(self):
"""
from .ldap_app import PpLdapAppError, PpLdapApplication
-__version__ = '0.4.3'
+__version__ = '0.4.4'
LOG = logging.getLogger(__name__)
self.chroot_homedir = self.default_chroot_homedir
self.home_root_abs = self.default_home_root
self.home_root_rel = os.path.relpath(self.home_root_abs, os.sep)
- self.simulate = False
+ self.show_simulate_opt = True
self.user_entries = []
self.users = {}
self.home_root_real = os.path.join(self.chroot_homedir, self.home_root_rel)
self.initialized = True
- # -------------------------------------------------------------------------
- def init_arg_parser(self):
- """
- Method to initiate the argument parser.
-
- This method should be explicitely called by all init_arg_parser()
- methods in descendant classes.
- """
-
- super(PpMkHomeApp, self).init_arg_parser()
-
- self.arg_parser.add_argument(
- "-s", "--simulate",
- action='store_true',
- dest='simulate',
- help="Simulation af all actions, nothing is really done."
- )
-
- # -------------------------------------------------------------------------
- def perform_arg_parser(self):
- """
- Public available method to execute some actions after parsing
- the command line parameters.
-
- Descendant classes may override this method.
- """
-
- super(PpMkHomeApp, self).perform_arg_parser()
-
- if self.args.simulate:
- self.simulate = True
-
# -------------------------------------------------------------------------
def perform_config(self):
"""
- super(PpMkHomeApp, self).pre_run()
if os.geteuid():
msg = "Only root may execute this application."
LOG.error(msg)
LOG.error(msg)
self.exit(1)
- if self.simulate:
- LOG.warn("Simulation mode - nothing is really done.")
+ super(PpMkHomeApp, self).pre_run()
# -------------------------------------------------------------------------
def _run(self):