From 6426fb1fee796b5c01d25e3fa497558ed13a7c66 Mon Sep 17 00:00:00 2001
From: Christian Heimes <cheimes@redhat.com>
Date: Sun, 16 Aug 2015 19:00:00 +0200
Subject: [PATCH 26/34] Py3 modernization: libmodernize.fixes.fix_input_six

In Python 3 raw_input() has been renamed to input() and the old,
insecure input() builtin is gone. six.moves simplifies the transition.
It provides the former raw_input() function under the same import name
on Python 2 and 3.
---
 base/common/python/pki/__init__.py                    |  5 ++++-
 base/server/python/pki/server/deployment/pkiconfig.py | 11 +++++++----
 base/server/python/pki/server/deployment/pkiparser.py |  4 +++-
 specs/pki-core.spec                                   |  2 ++
 4 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/base/common/python/pki/__init__.py b/base/common/python/pki/__init__.py
index 717c4fdeb6eabc6f826b9475b42d2eac14775638..6bfb82719e929ed9eafc1d03865e6f2a0fef6f91 100644
--- a/base/common/python/pki/__init__.py
+++ b/base/common/python/pki/__init__.py
@@ -23,11 +23,14 @@ This module contains top-level classes and functions used by the Dogtag project.
 """
 from __future__ import absolute_import
 from __future__ import print_function
+
 from functools import wraps
 import os
 import re
 import sys
+
 import requests
+from six.moves import input   # pylint: disable=W0622
 
 
 CONF_DIR = '/etc/pki'
@@ -68,7 +71,7 @@ def read_text(message,
     done = False
     value = None
     while not done:
-        value = raw_input(message)
+        value = input(message)
         value = value.strip()
 
         if len(value) == 0:  # empty value
diff --git a/base/server/python/pki/server/deployment/pkiconfig.py b/base/server/python/pki/server/deployment/pkiconfig.py
index c22698cb6bc8b7809d3711ee7c6e52e238775638..bb99e8e3159c9cb55d499452b078f8ae8bc04ad6 100644
--- a/base/server/python/pki/server/deployment/pkiconfig.py
+++ b/base/server/python/pki/server/deployment/pkiconfig.py
@@ -21,6 +21,9 @@
 
 # PKI Deployment Constants
 from __future__ import print_function
+from __future__ import absolute_import
+from six.moves import input  # pylint: disable=W0622
+
 PKI_DEPLOYMENT_DEFAULT_CLIENT_DIR_PERMISSIONS = 0o0755
 PKI_DEPLOYMENT_DEFAULT_DIR_PERMISSIONS = 0o0770
 PKI_DEPLOYMENT_DEFAULT_EXE_PERMISSIONS = 0o0770
@@ -139,8 +142,8 @@ def prepare_for_an_external_java_debugger(instance):
     print("              \"address=8000,server=y,suspend=n \"")
     print("              \"-Djava.awt.headless=true -Xmx128M\"")
     print()
-    raw_input("Enable external java debugger 'JAVA_OPTS' "
-              "and press return to continue  . . . ")
+    input("Enable external java debugger 'JAVA_OPTS' "
+          "and press return to continue  . . . ")
     print()
     print(PKI_DEPLOYMENT_INTERRUPT_BANNER)
     print()
@@ -155,8 +158,8 @@ def wait_to_attach_an_external_java_debugger():
     print("the 'address' selected by 'JAVA_OPTS' (e. g. - port 8000) and")
     print("set any desired breakpoints")
     print()
-    raw_input("Please attach an external java debugger "
-              "and press return to continue  . . . ")
+    input("Please attach an external java debugger "
+          "and press return to continue  . . . ")
     print()
     print(PKI_DEPLOYMENT_INTERRUPT_BANNER)
     print()
diff --git a/base/server/python/pki/server/deployment/pkiparser.py b/base/server/python/pki/server/deployment/pkiparser.py
index 9f7777ec5934c5f626f237b53cc640f9a77298f7..6bd67d3c70862d2a8f352e817d6612533317e950 100644
--- a/base/server/python/pki/server/deployment/pkiparser.py
+++ b/base/server/python/pki/server/deployment/pkiparser.py
@@ -35,6 +35,8 @@ import subprocess
 import xml.etree.ElementTree as ET
 from urlparse import urlparse
 
+from six.moves import input  # pylint: disable=W0622
+
 # PKI Imports
 import pki
 import pki.upgrade
@@ -262,7 +264,7 @@ class PKIConfigParser:
 
         done = False
         while not done:
-            value = raw_input(message)
+            value = input(message)
             value = value.strip()
 
             if len(value) == 0:  # empty value
diff --git a/specs/pki-core.spec b/specs/pki-core.spec
index a872b1b6e9aff6e89bf193aa87df36ed20abcfdd..15e8b040df8cc7a1554a298949358e500c2af54c 100644
--- a/specs/pki-core.spec
+++ b/specs/pki-core.spec
@@ -107,6 +107,7 @@ BuildRequires:    pylint
 
 BuildRequires:    python-nss
 BuildRequires:    python-requests
+BuildRequires:    python-six
 BuildRequires:    libselinux-python
 BuildRequires:    policycoreutils-python
 %if 0%{?fedora} >= 23
@@ -286,6 +287,7 @@ Requires:         ldapjdk
 Requires:         python-ldap
 Requires:         python-lxml
 Requires:         python-requests >= 1.1.0-3
+Requires:         python-six
 
 %if 0%{?rhel}
 # 'resteasy-base' is a subset of the complete set of
-- 
2.4.3

