From 60b1c0f8096f8f1b30290f62d9700214a8e078a6 Mon Sep 17 00:00:00 2001 From: f3flight Date: Tue, 24 May 2016 19:12:19 +0000 Subject: [PATCH] Fix regression in previous commit, fix unicode issues --- rq.yaml | 8 ++++---- timmy/nodes.py | 4 ++-- timmy/tools.py | 9 +++++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/rq.yaml b/rq.yaml index 2fbda0b..a31adcf 100644 --- a/rq.yaml +++ b/rq.yaml @@ -13,24 +13,24 @@ filelists: ubuntu: [etc-apt] scripts: by_release: - '4.1' + '4.1': by_roles: controller: [nova-manage-vm-list] '4.1.1': by_roles: fuel: [fuel-postgres-dump] controller: [nova-manage-vm-list] - '5.0' + '5.0': by_roles: controller: [nova-manage-vm-list] '5.0.1': by_roles: fuel: [fuel-docker-ps, fuel-dockerctl-check, fuel-docker-db-archive] controller: [nova-manage-vm-list] - '5.1' + '5.1': by_roles: controller: [nova-manage-vm-list] - '5.1.1' + '5.1.1': by_roles: fuel: [fuel-dockerctl-list, fuel-docker-ps, fuel-dockerctl-check, fuel-docker-db-archive] controller: [nova-manage-vm-list] diff --git a/timmy/nodes.py b/timmy/nodes.py index c84bead..83ca4e6 100644 --- a/timmy/nodes.py +++ b/timmy/nodes.py @@ -184,7 +184,7 @@ class Node(object): self.check_code(code, 'exec_cmd', c[cmd], ok_codes) try: with open(dfile, 'w') as df: - df.write(outs) + df.write(outs.encode('utf-8')) except: logging.error("exec_cmd: can't write to file %s" % dfile) @@ -209,7 +209,7 @@ class Node(object): self.check_code(code, 'exec_cmd', 'script %s' % f, ok_codes) try: with open(dfile, 'w') as df: - df.write(outs) + df.write(outs.encode('utf-8')) except: logging.error("exec_cmd: can't write to file %s" % dfile) return self diff --git a/timmy/tools.py b/timmy/tools.py index f5ffe9d..8e3c16d 100644 --- a/timmy/tools.py +++ b/timmy/tools.py @@ -192,10 +192,10 @@ def mdir(directory): def launch_cmd(cmd, timeout, input=None, ok_codes=None): def _log_msg(cmd, stderr, code, debug=False, stdin=None, stdout=None): - message = (u'launch_cmd:\n' + message = ('launch_cmd:\n' '___command: %s\n' '______code: %s\n' - '____stderr: %s' % (cmd, code, stderr.decode('utf-8'))) + '____stderr: %s' % (cmd, code, stderr)) if debug: message += '\n_____stdin: %s\n' % stdin message += '____stdout: %s' % stdout @@ -219,6 +219,8 @@ def launch_cmd(cmd, timeout, input=None, ok_codes=None): timeout_killer = threading.Timer(timeout, _timeout_terminate, [p.pid]) timeout_killer.start() outs, errs = p.communicate(input=input) + outs = outs.decode('utf-8') + errs = errs.decode('utf-8') errs = errs.rstrip('\n') except: try: @@ -226,12 +228,15 @@ def launch_cmd(cmd, timeout, input=None, ok_codes=None): except: pass outs, errs = p.communicate() + outs = outs.decode('utf-8') + errs = errs.decode('utf-8') errs = errs.rstrip('\n') logging.error(_log_msg(cmd, errs, p.returncode)) finally: if timeout_killer: timeout_killer.cancel() logging.info(_log_msg(cmd, errs, p.returncode)) + input = input.decode('utf-8') if input else None logging.debug(_log_msg(cmd, errs, p.returncode, debug=True, stdin=input, stdout=outs)) if p.returncode: