code: def fake_shell(self, func, stdout=False):
          
          dct = self.COMMAND_RESULT.copy()
          try:
              rc = func()
              if stdout:
                  dct['stdout'] = repr(rc)
          except mitogen.core.CallError:
              LOG.exception('While emulating a shell command')
              dct['rc'] = 1
              dct['stderr'] = traceback.format_exc()
  
          return dct
docs: Execute a function and decorate its return value in the style of
          _low_level_execute_command(). This produces a return value that looks
          like some shell command was run, when really func() was implemented
          entirely in Python.
  
          If the function raises :py:class:`mitogen.core.CallError`, this will be
          translated into a failed shell command with a non-zero exit status.
  
          :param func:
              Function invoked as `func()`.
          :returns:
              See :py:attr:`COMMAND_RESULT`.