From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id A6D582623B for ; Wed, 4 Jul 2018 05:59:46 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id s5LIDT9je1Q7 for ; Wed, 4 Jul 2018 05:59:46 -0400 (EDT) Received: from smtp47.i.mail.ru (smtp47.i.mail.ru [94.100.177.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 63F842165C for ; Wed, 4 Jul 2018 05:59:46 -0400 (EDT) From: Serge Petrenko Subject: [tarantool-patches] [PATCH] Replace net.box usage with console in tarantoolctl eval Date: Wed, 4 Jul 2018 12:59:02 +0300 Message-Id: <20180704095902.58607-1-sergepetrenko@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: Serge Petrenko Net.box usage for console is deprecated in 1.10, replaced it with console. Closes: #3490 --- https://github.com/tarantool/tarantool/tree/sergepetrenko/gh-3490-tarantoolctl-replace-netbox https://github.com/tarantool/tarantool/issues/3490 extra/dist/tarantoolctl.in | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in index 507ebe8bf..463d3e0a1 100755 --- a/extra/dist/tarantoolctl.in +++ b/extra/dist/tarantoolctl.in @@ -647,13 +647,29 @@ local function stdin_isatty() end local function execute_remote(uri, code) - local remote = netbox.connect(uri, { - console = true, connect_timeout = TIMEOUT_INFINITY - }) - if remote == nil then - return nil + local err, ret + console.on_start(function(self) + local cmd = string.format( + "require('console').connect('%s', { connect_timeout = %s })", + uri, TIMEOUT_INFINITY + ) + err = self:eval(cmd) + err = yaml.decode(err)[1] + if type(err) == 'table' and err.error then + err = false + else + ret = self:eval(code) + end + self.running = false + end) + console.on_client_disconnect(function(self) self.running = false end) + + console.start() + + if not err then + return false end - return true, remote:eval(code) + return true, ret end local function connect() -- 2.15.2 (Apple Git-101.1)