Hi Iwase-san, On Fri, 9 Dec 2016 09:23:33 +0900 Iwase Yusuke <iwase.yusu...@gmail.com> wrote:
> Hi, > > Thank you for reviewing my patch. > > > On 2016年12月09日 06:59, fumihiko kakuma wrote: > > Hi Iwase-san, > > > > On Mon, 5 Dec 2016 11:07:23 +0900 > > IWASE Yusuke <iwase.yusu...@gmail.com> wrote: > > > >> Signed-off-by: IWASE Yusuke <iwase.yusu...@gmail.com> > >> --- > >> ryu/tests/integrated/common/docker_base.py | 179 > >> ++++++++++++++--------------- > >> ryu/tests/integrated/common/quagga.py | 19 +-- > >> ryu/tests/integrated/common/ryubgp.py | 15 +-- > >> 3 files changed, 103 insertions(+), 110 deletions(-) > >> > > > > cut some lines > > > >> class Command(object): > >> @@ -107,39 +115,27 @@ class Command(object): > >> stdout=p_stdout, > >> stderr=p_stderr) > >> __stdout, __stderr = pop.communicate() > >> - try: > >> - if six.PY3 and isinstance(__stdout, six.binary_type): > >> - _stdout = __stdout.decode('ascii') > >> - else: > >> - _stdout = __stdout > >> - if six.PY3 and isinstance(__stderr, six.binary_type): > >> - _stderr = __stderr.decode('ascii') > >> - else: > >> - _stderr = __stderr > >> - except UnicodeError: > >> - _stdout = __stdout > >> - _stderr = __stderr > >> - out = CommandOut(_stdout if _stdout else "") > >> - out.stderr = _stderr if _stderr else "" > >> - out.command = cmd > >> - out.returncode = pop.returncode > >> + _stdout = six.text_type(__stdout, 'utf-8') > >> + _stderr = six.text_type(__stderr, 'utf-8') > > > > If result of command is bynary data, UnicodeError will be raised. > > Will you want it? > > Will UnicodeError be raised? > Sorry, if I'm misunderstanding, but I don't know why. > > As you said, the result of command is a binary type data. > OTOH, shell command outputs are usually encoded in utf-8, I guess. > Sorry, I think that I met a case handling binary data but I can not recall its detail. Let*s deal if we face the case. > >>> import subprocess > >>> from subprocess import PIPE > >>> pop = subprocess.Popen(['ls'], shell=True, stdout=PIPE, stderr=PIPE) > >>> __stdout, __stderr = pop.communicate() > >>> __stdout > b'CONTRIBUTING.rst\nLICENSE\nMANIFEST.in\nREADME.rst\nbin\ndebian\ndoc\netc\nrun_tests.sh\nryu\nsetup.cfg\nsetup.py\ntools\ntox.ini\nwork\n' > > So, we can decode '__stdout' with utf-8. > > >>> import six > >>> _stdout = six.text_type(__stdout, 'utf-8') > >>> _stdout > 'CONTRIBUTING.rst\nLICENSE\nMANIFEST.in\nREADME.rst\nbin\ndebian\ndoc\netc\nrun_tests.sh\nryu\nsetup.cfg\nsetup.py\ntools\ntox.ini\nwork\n' > > Is there any case we should concern including UnicodeError? > > > Thanks, > Iwase > > > > > Thanks, > > kakuma > > > >> + out = CommandOut(_stdout, _stderr, cmd, pop.returncode) > >> return out > >> > >> def execute(self, cmd, capture=True, try_times=1, interval=1): > >> + out = None > >> for i in range(try_times): > >> out = self._execute(cmd, capture=capture) > >> LOG.info(out.command) > >> if out.returncode == 0: > >> return out > >> - LOG.error("stdout: %s" % out) > >> - LOG.error("stderr: %s" % out.stderr) > >> + LOG.error("stdout: %s", out) > >> + LOG.error("stderr: %s", out.stderr) > >> if i + 1 >= try_times: > >> break > >> time.sleep(interval) > >> raise CommandError(out) > >> > >> def sudo(self, cmd, capture=True, try_times=1, interval=1): > >> - cmd = 'sudo ' + cmd > >> + cmd = 'sudo %s' % cmd > >> return self.execute(cmd, capture=capture, > >> try_times=try_times, interval=interval) > >> > > > > ------------------------------------------------------------------------------ > Developer Access Program for Intel Xeon Phi Processors > Access to Intel Xeon Phi processor-based developer platforms. > With one year of Intel Parallel Studio XE. > Training and support from Colfax. > Order your platform today.http://sdm.link/xeonphi > _______________________________________________ > Ryu-devel mailing list > Ryu-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/ryu-devel -- fumihiko kakuma <kak...@valinux.co.jp> ------------------------------------------------------------------------------ Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today.http://sdm.link/xeonphi _______________________________________________ Ryu-devel mailing list Ryu-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ryu-devel