import wizard as _wizard
from wizard import util
+"""This is the path to the wizard executable as specified
+by the caller; it lets us recursively invoke wizard"""
wizard = sys.argv[0]
-class CallError(_wizard.Error):
- def __init__(self, code, args, stdout, stderr):
- self.code = code
- self.args = args
- self.stdout = stdout
- self.stderr = stderr
- def __str__(self):
- return "CallError [%d]" % self.code
-
-class PythonCallError(CallError):
- def __init__(self, code, args, stdout, stderr):
- self.name = util.get_exception_name(stderr)
- CallError.__init__(self, code, args, stdout, stderr)
- def __str__(self):
- return "PythonCallError [%s]" % self.name
-
def is_python(args):
return args[0] == "python" or args[0] == wizard
uid = kwargs.pop("uid", None)
kwargs.setdefault("python", is_python(args))
if not user and not uid: return self.call(*args, **kwargs)
- if uid: return self.call("sudo", "-u", "#" + uid, *args, **kwargs)
+ if util.get_operator_name():
+ # This might be generalized as "preserve some environment"
+ args.insert(0, "SSH_GSSAPI_NAME=" + util.get_operator_name())
+ if uid: return self.call("sudo", "-u", "#" + str(uid), *args, **kwargs)
if user: return self.call("sudo", "-u", user, *args, **kwargs)
class ParallelShell(Shell):
def __init__(self, dry = False):
super(DummyParallelShell, self).__init__(dry=dry, max=1)
+class CallError(_wizard.Error):
+ def __init__(self, code, args, stdout, stderr):
+ self.code = code
+ self.args = args
+ self.stdout = stdout
+ self.stderr = stderr
+ def __str__(self):
+ return "CallError [%d]" % self.code
+
+class PythonCallError(CallError):
+ def __init__(self, code, args, stdout, stderr):
+ self.name = util.get_exception_name(stderr)
+ CallError.__init__(self, code, args, stdout, stderr)
+ def __str__(self):
+ return "PythonCallError [%s]" % self.name
+