def _exec_remote_with_pty(self, task_name, *args): stream_proto = AttachStdinProtocol() stdio.StandardIO(stream_proto) from mcloud.remote import Client, Task client = Client(host=self.host, port=self.port, settings=self.settings) try: yield txtimeout(client.connect(), 20, 'Can\'t connect to the server on host %s' % self.host) task = Task(task_name) task.on_progress = self.print_progress task.on_stdout = stream_proto.write stream_proto.listener = task.on_stdin try: yield client.call(task, *args, size=stream_proto.term.get_size()) res = yield task.wait_result() yield client.shutdown() yield sleep(0.1) defer.returnValue(res) except Exception as e: print repr(e) print('Failed to execute the task: %s' % e.message) except ConnectionRefusedError: print 'Can\'t connect to mcloud server' finally: stream_proto.stop()
def _remote_exec(self, task_name, *args, **kwargs): from mcloud.remote import Client, Task client = Client(host=self.host, port=self.port, settings=self.settings) self.current_client = client yield txtimeout(client.connect(), 20, 'Can\'t connect to the server on host %s' % self.host) task = Task(task_name) task.on_progress = self.print_progress self.current_task = task yield client.call(task, *args, **kwargs) res = yield task.wait_result() yield client.shutdown() yield sleep(0.1) defer.returnValue(res)
def _remote_exec(self, task_name, *args, **kwargs): from mcloud.remote import Client, Task client = Client(host=self.host, port=self.port, settings=self.settings) self.current_client = client yield txtimeout(client.connect(), 20, 'Can\'t connect to the server on host %s' % self.host) task = Task(task_name) task.on_progress = self.print_progress self.current_task = task yield client.call(task, *args, **kwargs) res = yield task.wait_result() yield client.shutdown() yield sleep(0.1) defer.returnValue(res)
def _exec_remote_with_pty(self, task_name, *args): stream_proto = AttachStdinProtocol() stdio.StandardIO(stream_proto) from mcloud.remote import Client, Task client = Client(host=self.host, port=self.port, settings=self.settings) try: yield txtimeout( client.connect(), 20, 'Can\'t connect to the server on host %s' % self.host) task = Task(task_name) task.on_progress = self.print_progress task.on_stdout = stream_proto.write stream_proto.listener = task.on_stdin try: yield client.call(task, *args, size=stream_proto.term.get_size()) res = yield task.wait_result() yield client.shutdown() yield sleep(0.1) defer.returnValue(res) except Exception as e: print repr(e) print('Failed to execute the task: %s' % e.message) except ConnectionRefusedError: print 'Can\'t connect to mcloud server' finally: stream_proto.stop()