From a4679d79ac8fe3d6b2b4cb4a1c2b215c360bb93f Mon Sep 17 00:00:00 2001 From: hankei6km Date: Sun, 11 Feb 2018 05:51:59 +0000 Subject: [PATCH] Support docker sdk for python 3.0.1 Docker sdk python 3.0.x has changed typof return object in `Container#exec_run`. --- setup.cfg | 2 +- xrosfs/conshell.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index eeccb82..a82cfc1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = xrosfs -version = 0.1.0 +version = 0.1.1 url = https://github.com/hankei6km/xrosfs author = hankei6km author_email = hankei6km@gmail.com diff --git a/xrosfs/conshell.py b/xrosfs/conshell.py index 6529c08..998e800 100644 --- a/xrosfs/conshell.py +++ b/xrosfs/conshell.py @@ -193,8 +193,16 @@ def _get_shell_item(self): return ret def _open_stream(self): - self.sh_stream = self.stream_exec( + exec_result = self.stream_exec( ' '.join((self._shell_path, self._shell_args))) + # if hasattr(exec_result, 'output'): + # https://stackoverflow.com/questions/5008828/convert-a-python-type-object-to-a-string + if type(exec_result).__name__ is 'ExecResult': + # docker sdk for python 3.0.x return tuple of (exit_code, output). + # ExecResult#output works as return value of sdk2.x. + self.sh_stream = exec_result.output + else: + self.sh_stream = exec_result def _switch_to_support_shell(self): item = self._get_shell_item()