diff options
author | Toshio Kuratomi <a.badger@gmail.com> | 2018-03-19 09:10:50 -0700 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2018-03-29 15:16:51 -0700 |
commit | 133afbaebef831152c9de7baf131d2438bfe5773 (patch) | |
tree | 328a269b66f4d02fa30382ae70184203328e2519 | |
parent | 783f901919d2df21c27ee66c9369cd820bf06995 (diff) | |
download | ansible-133afbaebef831152c9de7baf131d2438bfe5773.tar.gz |
Compare byte strings to byte strings
* Fix a traceback in ansible-pull on python3 comparing output from
subprocess with a text string.
* Rename variables that hold byte strings so we are clear that those are
not text strings.
* Use to_text() to transform variable that's being displayed as it's
less fragile than str().
Fixes #36962
(cherry picked from commit b98ad3a12b36c1ba2f7955e81731e739c8556a96)
-rw-r--r-- | lib/ansible/cli/pull.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/ansible/cli/pull.py b/lib/ansible/cli/pull.py index 42fb4e7bc1..e0ff0c94a1 100644 --- a/lib/ansible/cli/pull.py +++ b/lib/ansible/cli/pull.py @@ -30,7 +30,7 @@ import time from ansible.cli import CLI from ansible.errors import AnsibleOptionsError -from ansible.module_utils._text import to_native +from ansible.module_utils._text import to_native, to_text from ansible.plugins.loader import module_loader from ansible.utils.cmd_functions import run_cmd @@ -219,14 +219,14 @@ class PullCLI(CLI): # RUN the Checkout command display.debug("running ansible with VCS module to checkout repo") display.vvvv('EXEC: %s' % cmd) - rc, out, err = run_cmd(cmd, live=True) + rc, b_out, b_err = run_cmd(cmd, live=True) if rc != 0: if self.options.force: display.warning("Unable to update repository. Continuing with (forced) run of playbook.") else: return rc - elif self.options.ifchanged and '"changed": true' not in out: + elif self.options.ifchanged and b'"changed": true' not in b_out: display.display("Repository has not changed, quitting.") return 0 @@ -268,14 +268,14 @@ class PullCLI(CLI): # RUN THE PLAYBOOK COMMAND display.debug("running ansible-playbook to do actual work") display.debug('EXEC: %s' % cmd) - rc, out, err = run_cmd(cmd, live=True) + rc, b_out, b_err = run_cmd(cmd, live=True) if self.options.purge: os.chdir('/') try: shutil.rmtree(self.options.dest) except Exception as e: - display.error("Failed to remove %s: %s" % (self.options.dest, str(e))) + display.error(u"Failed to remove %s: %s" % (self.options.dest, to_text(e))) return rc |