]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Merge "Make sure we return unicode strings for process output"
authorJenkins <jenkins@review.openstack.org>
Tue, 24 Nov 2015 05:13:18 +0000 (05:13 +0000)
committerGerrit Code Review <review@openstack.org>
Tue, 24 Nov 2015 05:13:18 +0000 (05:13 +0000)
1  2 
neutron/agent/linux/async_process.py
neutron/agent/linux/utils.py
neutron/common/utils.py
neutron/tests/common/helpers.py
neutron/tests/unit/common/test_utils.py

Simple merge
index 95619a98d46614e9171bc3f8929d37627cb44a94,5bbc1bf0198302f569c1fc267d5c4ffaa33b50cb..29d129ad1a26bf81ad553e6806c03ff20166381c
@@@ -120,30 -119,35 +120,27 @@@ def execute(cmd, process_input=None, ad
              _stdout, _stderr = obj.communicate(_process_input)
              returncode = obj.returncode
              obj.stdin.close()
-         if six.PY3:
-             if isinstance(_stdout, bytes):
-                 _stdout = _stdout.decode('utf-8', 'surrogateescape')
-             if isinstance(_stderr, bytes):
-                 _stderr = _stderr.decode('utf-8', 'surrogateescape')
+         _stdout = utils.safe_decode_utf8(_stdout)
+         _stderr = utils.safe_decode_utf8(_stderr)
  
 -        command_str = {
 -            'cmd': cmd,
 -            'code': returncode
 -        }
 -        m = _("\nCommand: %(cmd)s"
 -              "\nExit code: %(code)d\n") % command_str
 -
          extra_ok_codes = extra_ok_codes or []
 -        if returncode and returncode in extra_ok_codes:
 -            returncode = None
 -
 -        if returncode and log_fail_as_error:
 -            command_str['stdin'] = process_input or ''
 -            command_str['stdout'] = _stdout
 -            command_str['stderr'] = _stderr
 -            m += _("Stdin: %(stdin)s\n"
 -                  "Stdout: %(stdout)s\n"
 -                  "Stderr: %(stderr)s") % command_str
 -            log_msg = m.strip().replace('\n', '; ')
 -            LOG.error(log_msg)
 +        if returncode and returncode not in extra_ok_codes:
 +            msg = _("Exit code: %(returncode)d; "
 +                    "Stdin: %(stdin)s; "
 +                    "Stdout: %(stdout)s; "
 +                    "Stderr: %(stderr)s") % {
 +                        'returncode': returncode,
 +                        'stdin': process_input or '',
 +                        'stdout': _stdout,
 +                        'stderr': _stderr}
 +
 +            if log_fail_as_error:
 +                LOG.error(msg)
 +            if check_exit_code:
 +                raise RuntimeError(msg)
          else:
 -            log_msg = m.strip().replace('\n', '; ')
 -            LOG.debug(log_msg)
 +            LOG.debug("Exit code: %d", returncode)
  
 -        if returncode and check_exit_code:
 -            raise RuntimeError(m)
      finally:
          # NOTE(termie): this appears to be necessary to let the subprocess
          #               call clean something up in between calls, without
Simple merge
Simple merge