Ejemplo n.º 1
0
 def start(self, command=None):
     command = command or self.command
     if not self.Has(self.name):
         Tmux.EnsureSession(self.name)
         Tmux.EnsureWindow(self.name, "daemon")
     if Tmux.IsResponsive(self.name, "daemon"):
         if not command:
             command = Tmux.Run(self.name, "daemon", "echo $DAEMON_COMMAND")
         # We assume that the daemon's will not detach from tmux, so if
         # the shell is not responsive, it means the daemon is running
         Tmux.Write(
             self.name, "daemon", "export DAEMON_COMMAND=\"{0}\"".format(
                 command.replace('"', '\\"')))
         Tmux.Write(self.name, "daemon", command)
     return True
Ejemplo n.º 2
0
 def stop(self):
     if self.Has(self.name):
         # This sends a Ctrl-C.
         Tmux.Write(self.name, "daemon", "C-c")
         # If the window does not become responsive after 5s, we kill the
         # window.
         if not Tmux.IsResponsive(self.name, "daemon", timeout=5):
             Tmux.KillWindow(self.name, "daemon")
         return True
     else:
         return False