Commit 913f59fd authored by Sébastien Luttringer's avatar Sébastien Luttringer
Browse files

Use sjrpc wait_shutdown API (v18)

parent 38f43471
Loading
Loading
Loading
Loading
+5 −19
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@ CloudControl Console related commands
from cccli.command import TqlCommand
from cccli.exception import *
from cccli.printer import Printer, color
from sjrpc.core import AsyncWatcher
from sjrpc.core.exceptions import *
from sjrpc.core.protocols import TunnelProtocol
import fcntl
@@ -17,7 +16,6 @@ import signal
import struct
import sys
import termios
import threading
import time
import tty

@@ -100,17 +98,12 @@ class Command_shell(TqlCommand):
        tun = self.rpc.create_tunnel(obj["output"], endpoint=FakeTtySocket())
        try:
            signal.signal(signal.SIGWINCH, _cb_sig_resize)
            # we need an async watcher to be able to handle sigwinch
            watcher = AsyncWatcher()
            watcher.register(self.rpc.rpc, "shell_wait", obj["output"])
            watcher.wait()
            tun.wait_shutdown()
        finally:
            # restore original signal
            signal.signal(signal.SIGWINCH, signal.SIG_DFL)
            # shutdown is empty, useless
            #tun.shutdown()
            # close tunnel if sjrpc doesn't do it
            tun.close()
            tun.shutdown()

    def remote_functions(self):
        return set(("shell",))
@@ -138,18 +131,11 @@ class Command_console(TqlCommand):
        if obj['status'] != 'success':
            raise cmdError("%s: %s" % (obj["status"], obj["message"]))
        # Connect to remote end using sjrpc
        ev = threading.Event()
        def cb_on_close(tun):
            tun.cb_default_on_close(tun)
            ev.set()
        tun = self.rpc.create_tunnel(obj["output"], endpoint=FakeTtySocket())
        try:
            tun = self.rpc.create_tunnel(obj["output"],
                                         endpoint=FakeTtySocket(),
                                         on_close=cb_on_close)
            ev.wait()
            tun.wait_shutdown()
        finally:
            # see tun.close in previous command
            tun.close()
            tun.shutdown()

    def remote_functions(self):
        return set(("console",))
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ Standards-Version: 3.8.0

Package: cc-cli
Architecture: all
Depends: ${misc:Depends}, ${python:Depends}, python (>= 2.6), python-sjrpc (>= 14), python-xdg
Depends: ${misc:Depends}, ${python:Depends}, python (>= 2.6), python-sjrpc (>= 18), python-xdg
XB-Python-Version: ${python:Versions}
Description: CloudControl CLI
 This package provides the Command Line Interface to CloudControl.