From 506f7824fb8bcb3eadd557bfeb5cdaf20ada8f82 Mon Sep 17 00:00:00 2001 From: Chris Hambridge Date: Tue, 15 Aug 2017 14:40:38 -0400 Subject: [PATCH] Resolve scan issues with python 3.6. Closes #97. --- rho/scancommand.py | 4 ++-- rho/utilities.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/rho/scancommand.py b/rho/scancommand.py index 1307ff1..f346d28 100644 --- a/rho/scancommand.py +++ b/rho/scancommand.py @@ -24,7 +24,7 @@ from rho import utilities from rho.clicommand import CliCommand from rho.vault import get_vault_and_password -from rho.utilities import multi_arg, _read_in_file, str_to_ascii +from rho.utilities import multi_arg, _read_in_file, str_to_ascii, iteritems from rho.translation import _ @@ -136,7 +136,7 @@ def _create_hosts_auths_file(success_map, profile): '---' \ '---' \ '---\n' - for host, line in success_map.iteritems(): + for host, line in iteritems(success_map): string_to_write += host + '\n----------------------\n' for auth in line: string_to_write += ', '.join(auth[1:3]) + ', ********, ' +\ diff --git a/rho/utilities.py b/rho/utilities.py index 4a1ac52..235b8f2 100644 --- a/rho/utilities.py +++ b/rho/utilities.py @@ -210,7 +210,10 @@ def str_to_ascii(in_string): :param in_string: input string to convert to ascii :returns: ASCII encoded string """ - return str.encode(in_string, 'ascii') + if sys.version_info.major == 2: + return in_string.decode('utf-8').encode('ascii') + + return in_string def iteritems(dictionary):