示例#1
0
 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)
示例#2
0
 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)
示例#3
0
 def wrapper(args, cfg):
     if os.getuid() != 0:
         raise exceptions.NonRootUserError()
     if not cfg.is_attached:
         raise exceptions.UnattachedError()
     return func(args, cfg)