diff options
Diffstat (limited to 'base/server/python/pki/server')
4 files changed, 33 insertions, 25 deletions
diff --git a/base/server/python/pki/server/cli/nuxwdog.py b/base/server/python/pki/server/cli/nuxwdog.py index 674fc0340..bdcc18a00 100644 --- a/base/server/python/pki/server/cli/nuxwdog.py +++ b/base/server/python/pki/server/cli/nuxwdog.py @@ -119,7 +119,7 @@ class NuxwdogEnableCLI(pki.cli.CLI): def add_nuxwdog_link(self, instance): nuxwdog_jar_path = '/usr/lib/java/nuxwdog.jar' if not os.path.exists(nuxwdog_jar_path): - print ( + print( "Error: nuxwdog jar file does not exist. " "Is nuxwdog installed?" ) @@ -158,7 +158,7 @@ class NuxwdogEnableCLI(pki.cli.CLI): line = "USE_NUXWDOG=\"true\"\n" got_use_nuxwdog = True - sys.stdout.write(line) + print(line, end='') if not got_use_nuxwdog: with open(sysconfig_file, 'a') as f: @@ -247,7 +247,7 @@ class NuxwdogEnableCLI(pki.cli.CLI): match = re.search("^passwordClass=(.*)", line) if match: line = "passwordClass=" + pclass + "\n" - sys.stdout.write(line) + print(line, end='') os.chown(cs_cfg, instance.uid, instance.gid) @@ -336,7 +336,7 @@ class NuxwdogDisableCLI(pki.cli.CLI): if match: line = "USE_NUXWDOG=\"false\"\n" - sys.stdout.write(line) + print(line, end='') os.chown(sysconfig_file, instance.uid, instance.gid) @@ -402,5 +402,5 @@ class NuxwdogDisableCLI(pki.cli.CLI): match = re.search("^passwordClass=(.*)", line) if match: line = "passwordClass=" + pclass + "\n" - sys.stdout.write(line) + print(line, end='') os.chown(cs_cfg, instance.uid, instance.gid) diff --git a/base/server/python/pki/server/deployment/pkiconfig.py b/base/server/python/pki/server/deployment/pkiconfig.py index bb99e8e31..1198eea13 100644 --- a/base/server/python/pki/server/deployment/pkiconfig.py +++ b/base/server/python/pki/server/deployment/pkiconfig.py @@ -22,7 +22,7 @@ # PKI Deployment Constants from __future__ import print_function from __future__ import absolute_import -from six.moves import input # pylint: disable=W0622 +from six.moves import input # pylint: disable=W0622,F0401 PKI_DEPLOYMENT_DEFAULT_CLIENT_DIR_PERMISSIONS = 0o0755 PKI_DEPLOYMENT_DEFAULT_DIR_PERMISSIONS = 0o0770 diff --git a/base/server/python/pki/server/deployment/pkihelper.py b/base/server/python/pki/server/deployment/pkihelper.py index 821739bc5..e6833d270 100644 --- a/base/server/python/pki/server/deployment/pkihelper.py +++ b/base/server/python/pki/server/deployment/pkihelper.py @@ -30,10 +30,13 @@ import fileinput import re import requests.exceptions import shutil -from shutil import Error, WindowsError +from shutil import Error +try: + from shutil import WindowsError # pylint: disable=E0611 +except ImportError: + WindowsError = None import subprocess import time -import types from datetime import datetime from grp import getgrgid from grp import getgrnam @@ -1722,7 +1725,7 @@ class File: self.slots[slot], self.mdict[slot], extra=config.PKI_INDENTATION_LEVEL_3) line = line.replace(self.slots[slot], self.mdict[slot]) - sys.stdout.write(line) + print(line, end='') if uid is None: uid = self.identity.get_uid() if gid is None: @@ -3805,7 +3808,7 @@ class ConfigClient: extra=config.PKI_INDENTATION_LEVEL_2) certs = [] - if not isinstance(certs, types.ListType): + if not isinstance(certs, list): certs = [certs] for cdata in certs: if (self.subsystem == "CA" and self.external and @@ -3897,11 +3900,12 @@ class ConfigClient: extra=config.PKI_INDENTATION_LEVEL_2) if hasattr(e, 'response'): + text = e.response.text # pylint: disable=E1101 try: - root = ET.fromstring(e.response.text) + root = ET.fromstring(text) except ET.ParseError as pe: config.pki_log.error( - "ParseError: %s: %s " % (pe, e.response.text), + "ParseError: %s: %s " % (pe, text), extra=config.PKI_INDENTATION_LEVEL_2) raise diff --git a/base/server/python/pki/server/deployment/pkiparser.py b/base/server/python/pki/server/deployment/pkiparser.py index 1bb15867b..6eeb74346 100644 --- a/base/server/python/pki/server/deployment/pkiparser.py +++ b/base/server/python/pki/server/deployment/pkiparser.py @@ -22,7 +22,6 @@ # System Imports from __future__ import absolute_import from __future__ import print_function -import ConfigParser import argparse import getpass import ldap @@ -33,9 +32,11 @@ import requests.exceptions import string import subprocess import xml.etree.ElementTree as ET -from urlparse import urlparse -from six.moves import input, range # pylint: disable=W0622 +from six.moves import input, range # pylint: disable=W0622,F0401 +from six.moves import configparser # pylint: disable=F0401 +from six.moves.urllib.parse import urlparse # pylint: disable=F0401 + # PKI Imports import pki @@ -191,7 +192,7 @@ class PKIConfigParser: application_version = str(pki.upgrade.Version( pki.implementation_version())) - self.pki_config = ConfigParser.SafeConfigParser({ + self.pki_config = configparser.SafeConfigParser({ 'application_version': application_version, 'pki_instance_name': default_instance_name, 'pki_http_port': default_http_port, @@ -208,7 +209,7 @@ class PKIConfigParser: # Make keys case-sensitive! self.pki_config.optionxform = str - config.user_config = ConfigParser.SafeConfigParser() + config.user_config = configparser.SafeConfigParser() config.user_config.optionxform = str with open(config.default_deployment_cfg) as f: @@ -263,6 +264,7 @@ class PKIConfigParser: message = ' ' * self.indent + message + sign + ' ' done = False + value = '' while not done: value = input(message) value = value.strip() @@ -355,10 +357,11 @@ class PKIConfigParser: try: val = self.pki_config.get( section, key, raw=True) + val = val.replace("%", "%%") # pylint: disable=E1101 if val: self.pki_config.set( - section, key, val.replace("%", "%%")) - except ConfigParser.NoOptionError: + section, key, val) + except configparser.NoOptionError: continue sections = config.user_config.sections() @@ -369,12 +372,13 @@ class PKIConfigParser: try: val = config.user_config.get( section, key, raw=True) + val = val.replace("%", "%%") # pylint: disable=E1101 if val: config.user_config.set( - section, key, val.replace("%", "%%")) - except ConfigParser.NoOptionError: + section, key, val) + except configparser.NoOptionError: continue - except ConfigParser.ParsingError as err: + except configparser.ParsingError as err: print(err) rv = err return rv @@ -1290,7 +1294,7 @@ class PKIConfigParser: config.pki_log.error(log.PKIHELPER_DICTIONARY_MASTER_MISSING_KEY_1, err, extra=config.PKI_INDENTATION_LEVEL_2) raise - except ConfigParser.InterpolationSyntaxError as err: + except configparser.InterpolationSyntaxError as err: config.pki_log.error(log.PKIHELPER_DICTIONARY_INTERPOLATION_1, extra=config.PKI_INDENTATION_LEVEL_2) config.pki_log.error(log.PKIHELPER_DICTIONARY_INTERPOLATION_2, err, @@ -1303,13 +1307,13 @@ class PKIConfigParser: the appropriate PKI slots dictionary""" rv = 0 try: - parser = ConfigParser.ConfigParser() + parser = configparser.ConfigParser() # Make keys case-sensitive! parser.optionxform = str parser.read(config.PKI_DEPLOYMENT_SLOTS_CONFIGURATION_FILE) # Slots configuration file name/value pairs self.slots_dict = dict(parser.items('Tomcat')) - except ConfigParser.ParsingError as err: + except configparser.ParsingError as err: rv = err return rv |