From 0fbc8918e883b63ad21690eaf75fc6654294cedc Mon Sep 17 00:00:00 2001 From: Herkermer Sherwood Date: Wed, 9 Dec 2015 08:42:57 -0800 Subject: [PATCH 1/7] Modify tag from bytes to string --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 66de9b7..c97c434 100644 --- a/setup.py +++ b/setup.py @@ -74,6 +74,7 @@ def parse_version_tag(tag): Returns a tuple of the version number, number of commits (if any), and the Git SHA (if available). ''' + tag = tag.decode() if not tag or '-g' not in tag: return tag, None, None From 10b8b250b0de52f9991eedd3e3e9eb939164f574 Mon Sep 17 00:00:00 2001 From: Herkermer Sherwood Date: Wed, 9 Dec 2015 08:44:20 -0800 Subject: [PATCH 2/7] Use new configparser import --- pepper/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pepper/cli.py b/pepper/cli.py index b6d97fb..fa9f4f3 100644 --- a/pepper/cli.py +++ b/pepper/cli.py @@ -8,7 +8,7 @@ import optparse import os import textwrap -import ConfigParser +from configparser import ConfigParser import getpass import time From 5a15480345f47b764390bab016d13c4587422e16 Mon Sep 17 00:00:00 2001 From: Herkermer Sherwood Date: Wed, 9 Dec 2015 08:44:35 -0800 Subject: [PATCH 3/7] Modify to use recommended ConfigParser Using ConfigParser(interpolation=None) in place of RawConfigParser. Recommended by https://docs.python.org/3/library/configparser.html#configparser.RawConfigParser. --- pepper/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pepper/cli.py b/pepper/cli.py index fa9f4f3..e4dcbf6 100644 --- a/pepper/cli.py +++ b/pepper/cli.py @@ -191,7 +191,7 @@ def get_login_details(self): 'SALTAPI_EAUTH': 'auto', } - config = ConfigParser.RawConfigParser() + config = ConfigParser(interpolation=None) config.read(self.options.config) # read file From 817aea6b8831e59e212625b633f32357e449dd3a Mon Sep 17 00:00:00 2001 From: Herkermer Sherwood Date: Wed, 9 Dec 2015 08:56:11 -0800 Subject: [PATCH 4/7] Modify to use Python 3 __next__() From PEP 3114 --- pepper/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pepper/cli.py b/pepper/cli.py index e4dcbf6..51ecfd3 100644 --- a/pepper/cli.py +++ b/pepper/cli.py @@ -324,7 +324,7 @@ def run(self): load = self.parse_cmd() creds = iter(self.parse_login()) - api = pepper.Pepper(creds.next(), debug_http=self.options.debug_http, ignore_ssl_errors=self.options.ignore_ssl_certificate_errors) + api = pepper.Pepper(creds.__next__(), debug_http=self.options.debug_http, ignore_ssl_errors=self.options.ignore_ssl_certificate_errors) auth = api.login(*list(creds)) if self.options.fail_if_minions_dont_respond: From cb3d3757d5aaee454a44f3dc90c4e51b5e5fe106 Mon Sep 17 00:00:00 2001 From: Herkermer Sherwood Date: Wed, 9 Dec 2015 09:58:26 -0800 Subject: [PATCH 5/7] Import and use ConfigParser based on version This is intended to all support back to Python 2. --- pepper/cli.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pepper/cli.py b/pepper/cli.py index 51ecfd3..8127ed6 100644 --- a/pepper/cli.py +++ b/pepper/cli.py @@ -8,9 +8,14 @@ import optparse import os import textwrap -from configparser import ConfigParser import getpass import time +try: + # Python 3 + from configparser import ConfigParser +except ImportError: + # Python 2 + import ConfigParser import pepper @@ -191,7 +196,10 @@ def get_login_details(self): 'SALTAPI_EAUTH': 'auto', } - config = ConfigParser(interpolation=None) + try: + config = ConfigParser(interpolation=None) + except TypeError as e: + config = ConfigParser.RawConfigParser() config.read(self.options.config) # read file From fc34a86b5d0672f22e629f50393642362fc4b8c7 Mon Sep 17 00:00:00 2001 From: Herkermer Sherwood Date: Wed, 9 Dec 2015 09:59:17 -0800 Subject: [PATCH 6/7] Use next function instead of underlying __next__() method This function was backported so it will work in Python 2.6+. --- pepper/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pepper/cli.py b/pepper/cli.py index 8127ed6..cbf64c0 100644 --- a/pepper/cli.py +++ b/pepper/cli.py @@ -332,7 +332,7 @@ def run(self): load = self.parse_cmd() creds = iter(self.parse_login()) - api = pepper.Pepper(creds.__next__(), debug_http=self.options.debug_http, ignore_ssl_errors=self.options.ignore_ssl_certificate_errors) + api = pepper.Pepper(next(creds), debug_http=self.options.debug_http, ignore_ssl_errors=self.options.ignore_ssl_certificate_errors) auth = api.login(*list(creds)) if self.options.fail_if_minions_dont_respond: From e1a454c2a404aef7674d55b42809f97960b51842 Mon Sep 17 00:00:00 2001 From: Herkermer Sherwood Date: Wed, 9 Dec 2015 10:01:40 -0800 Subject: [PATCH 7/7] Modify only to decode if tag is of type bytes It may have had unintended consequences elsewhere to unintentionally convert this str to unicode in Python 2. --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c97c434..c38a7bc 100644 --- a/setup.py +++ b/setup.py @@ -74,7 +74,8 @@ def parse_version_tag(tag): Returns a tuple of the version number, number of commits (if any), and the Git SHA (if available). ''' - tag = tag.decode() + if isinstance(tag, bytes): + tag = tag.decode() if not tag or '-g' not in tag: return tag, None, None