X-Git-Url: https://scripts.mit.edu/gitweb/wizard.git/blobdiff_plain/67f01d68d435ae46218008eaf4a3c91450080a64..6554c6378a6e801b4fe47c50688cdae1d627bc18:/wizard/shell.py diff --git a/wizard/shell.py b/wizard/shell.py index cda9eac..723b50d 100644 --- a/wizard/shell.py +++ b/wizard/shell.py @@ -131,6 +131,12 @@ class Shell(object): if self._async(proc, args, **kwargs): return proc stdout, stderr = proc.communicate(kwargs["input"]) + # can occur if we were doing interactive communication; i.e. + # we didn't pass in PIPE. + if stdout is None: + stdout = "" + if stderr is None: + stderr = "" if not kwargs["interactive"]: if kwargs["strip"]: self._log(None, stderr) @@ -151,7 +157,7 @@ class Shell(object): logging.debug("STDERR:\n" + stderr) def _wait(self): pass - def _async(self): + def _async(self, *args, **kwargs): return False def callAsUser(self, *args, **kwargs): """ @@ -188,6 +194,8 @@ class Shell(object): on working directory context. Keyword arguments are the same as :meth:`call`. """ + if os.getuid(): + return self.call(*args, **kwargs) uid = os.stat(os.getcwd()).st_uid # consider also checking ruid? if uid != os.geteuid(): @@ -307,6 +315,12 @@ class ParallelShell(Shell): return on_success(stdout, stderr) +# Setup a convenience global instance +shell = Shell() +call = shell.call +callAsUser = shell.callAsUser +safeCall = shell.safeCall +eval = shell.eval class DummyParallelShell(ParallelShell): """Same API as :class:`ParallelShell`, but doesn't actually