def new_f(args, cfg): if not cfg.is_attached: if unattached_msg_tmpl: name = getattr(args, "name", "None") msg = unattached_msg_tmpl.format(name=name) exception = exceptions.UnattachedError(msg) else: exception = exceptions.UnattachedError() raise exception return f(args, cfg)
def new_f(args, cfg, **kwargs): if not cfg.is_attached: if unattached_msg_tmpl: names = getattr(args, "service", "None") msg = unattached_msg_tmpl.format(name=", ".join(names)) exception = exceptions.UnattachedError(msg) else: exception = exceptions.UnattachedError() raise exception return f(args, cfg, **kwargs)
def wrapper(args, cfg): if os.getuid() != 0: raise exceptions.NonRootUserError() if not cfg.is_attached: raise exceptions.UnattachedError() return func(args, cfg)