diff options
author | Christian Heimes <cheimes@redhat.com> | 2015-08-16 19:00:00 +0200 |
---|---|---|
committer | Christian Heimes <cheimes@redhat.com> | 2015-08-17 21:14:11 +0200 |
commit | f98ca7fa1903e12a4b2c49a70163077b3560dc1d (patch) | |
tree | a3446113d3a7d32c5ce79b1b359d5353ec49afee /base/server/python/pki | |
parent | 71148b8f79a5d6ba0c949a3ca0acf5aec6321f0a (diff) | |
download | pki-f98ca7fa1903e12a4b2c49a70163077b3560dc1d.tar.gz pki-f98ca7fa1903e12a4b2c49a70163077b3560dc1d.tar.xz pki-f98ca7fa1903e12a4b2c49a70163077b3560dc1d.zip |
Py3 modernization: libmodernize.fixes.fix_print
Replace print statement with Python 3's print() function.
For Python 2 'from __future__ import print_function' turns the print
statement into Python 3 compatible print function.
See https://www.python.org/dev/peps/pep-3105/
Diffstat (limited to 'base/server/python/pki')
10 files changed, 212 insertions, 202 deletions
diff --git a/base/server/python/pki/server/cli/instance.py b/base/server/python/pki/server/cli/instance.py index f9e971e8a..f74d251ca 100644 --- a/base/server/python/pki/server/cli/instance.py +++ b/base/server/python/pki/server/cli/instance.py @@ -20,6 +20,7 @@ # from __future__ import absolute_import +from __future__ import print_function import getopt import os import sys @@ -45,8 +46,8 @@ class InstanceCLI(pki.cli.CLI): @staticmethod def print_instance(instance): - print ' Instance ID: %s' % instance.name - print ' Active: %s' % instance.is_active() + print(' Instance ID: %s' % instance.name) + print(' Active: %s' % instance.is_active()) class InstanceFindCLI(pki.cli.CLI): @@ -55,11 +56,11 @@ class InstanceFindCLI(pki.cli.CLI): super(InstanceFindCLI, self).__init__('find', 'Find instances') def print_help(self): - print 'Usage: pki-server instance-find [OPTIONS]' - print - print ' -v, --verbose Run in verbose mode.' - print ' --help Show help message.' - print + print('Usage: pki-server instance-find [OPTIONS]') + print() + print(' -v, --verbose Run in verbose mode.') + print(' --help Show help message.') + print() def execute(self, argv): @@ -68,7 +69,7 @@ class InstanceFindCLI(pki.cli.CLI): 'verbose', 'help']) except getopt.GetoptError as e: - print 'ERROR: ' + str(e) + print('ERROR: ' + str(e)) self.print_help() sys.exit(1) @@ -81,7 +82,7 @@ class InstanceFindCLI(pki.cli.CLI): sys.exit() else: - print 'ERROR: unknown option ' + o + print('ERROR: unknown option ' + o) self.print_help() sys.exit(1) @@ -101,7 +102,7 @@ class InstanceFindCLI(pki.cli.CLI): if first: first = False else: - print + print() instance = pki.server.PKIInstance(instance_name) instance.load() @@ -115,11 +116,11 @@ class InstanceShowCLI(pki.cli.CLI): super(InstanceShowCLI, self).__init__('show', 'Show instance') def print_help(self): - print 'Usage: pki-server instance-show [OPTIONS] <instance ID>' - print - print ' -v, --verbose Run in verbose mode.' - print ' --help Show help message.' - print + print('Usage: pki-server instance-show [OPTIONS] <instance ID>') + print() + print(' -v, --verbose Run in verbose mode.') + print(' --help Show help message.') + print() def execute(self, argv): @@ -128,12 +129,12 @@ class InstanceShowCLI(pki.cli.CLI): 'verbose', 'help']) except getopt.GetoptError as e: - print 'ERROR: ' + str(e) + print('ERROR: ' + str(e)) self.print_help() sys.exit(1) if len(args) != 1: - print 'ERROR: missing instance ID' + print('ERROR: missing instance ID') self.print_help() sys.exit(1) @@ -148,7 +149,7 @@ class InstanceShowCLI(pki.cli.CLI): sys.exit() else: - print 'ERROR: unknown option ' + o + print('ERROR: unknown option ' + o) self.print_help() sys.exit(1) @@ -164,11 +165,11 @@ class InstanceStartCLI(pki.cli.CLI): super(InstanceStartCLI, self).__init__('start', 'Start instance') def print_help(self): - print 'Usage: pki-server instance-start [OPTIONS] <instance ID>' - print - print ' -v, --verbose Run in verbose mode.' - print ' --help Show help message.' - print + print('Usage: pki-server instance-start [OPTIONS] <instance ID>') + print() + print(' -v, --verbose Run in verbose mode.') + print(' --help Show help message.') + print() def execute(self, argv): @@ -177,12 +178,12 @@ class InstanceStartCLI(pki.cli.CLI): 'verbose', 'help']) except getopt.GetoptError as e: - print 'ERROR: ' + str(e) + print('ERROR: ' + str(e)) self.print_help() sys.exit(1) if len(args) != 1: - print 'ERROR: missing instance ID' + print('ERROR: missing instance ID') self.print_help() sys.exit(1) @@ -197,7 +198,7 @@ class InstanceStartCLI(pki.cli.CLI): sys.exit() else: - print 'ERROR: unknown option ' + o + print('ERROR: unknown option ' + o) self.print_help() sys.exit(1) @@ -214,11 +215,11 @@ class InstanceStopCLI(pki.cli.CLI): super(InstanceStopCLI, self).__init__('stop', 'Stop instance') def print_help(self): - print 'Usage: pki-server instance-stop [OPTIONS] <instance ID>' - print - print ' -v, --verbose Run in verbose mode.' - print ' --help Show help message.' - print + print('Usage: pki-server instance-stop [OPTIONS] <instance ID>') + print() + print(' -v, --verbose Run in verbose mode.') + print(' --help Show help message.') + print() def execute(self, argv): @@ -227,12 +228,12 @@ class InstanceStopCLI(pki.cli.CLI): 'verbose', 'help']) except getopt.GetoptError as e: - print 'ERROR: ' + str(e) + print('ERROR: ' + str(e)) self.print_help() sys.exit(1) if len(args) != 1: - print 'ERROR: missing instance ID' + print('ERROR: missing instance ID') self.print_help() sys.exit(1) @@ -247,7 +248,7 @@ class InstanceStopCLI(pki.cli.CLI): sys.exit() else: - print 'ERROR: unknown option ' + o + print('ERROR: unknown option ' + o) self.print_help() sys.exit(1) @@ -264,13 +265,13 @@ class InstanceMigrateCLI(pki.cli.CLI): super(InstanceMigrateCLI, self).__init__('migrate', 'Migrate instance') def print_help(self): - print 'Usage: pki-server instance-migrate [OPTIONS] <instance ID>' - print - print ' --tomcat <version> Use the specified Tomcat version.' - print ' -v, --verbose Run in verbose mode.' - print ' --debug Show debug messages.' - print ' --help Show help message.' - print + print('Usage: pki-server instance-migrate [OPTIONS] <instance ID>') + print() + print(' --tomcat <version> Use the specified Tomcat version.') + print(' -v, --verbose Run in verbose mode.') + print(' --debug Show debug messages.') + print(' --help Show help message.') + print() def execute(self, argv): @@ -279,12 +280,12 @@ class InstanceMigrateCLI(pki.cli.CLI): 'tomcat=', 'verbose', 'debug', 'help']) except getopt.GetoptError as e: - print 'ERROR: ' + str(e) + print('ERROR: ' + str(e)) self.print_help() sys.exit(1) if len(args) != 1: - print 'ERROR: missing instance ID' + print('ERROR: missing instance ID') self.print_help() sys.exit(1) @@ -307,12 +308,12 @@ class InstanceMigrateCLI(pki.cli.CLI): sys.exit() else: - print 'ERROR: unknown option ' + o + print('ERROR: unknown option ' + o) self.print_help() sys.exit(1) if not tomcat_version: - print 'ERROR: missing Tomcat version' + print('ERROR: missing Tomcat version') self.print_help() sys.exit(1) @@ -338,11 +339,11 @@ class InstanceNuxwdogEnableCLI(pki.cli.CLI): 'Instance enable nuxwdog') def print_help(self): - print 'Usage: pki-server instance-nuxwdog-enable [OPTIONS] <instance ID>' - print - print ' -v, --verbose Run in verbose mode.' - print ' --help Show help message.' - print + print('Usage: pki-server instance-nuxwdog-enable [OPTIONS] <instance ID>') + print() + print(' -v, --verbose Run in verbose mode.') + print(' --help Show help message.') + print() def execute(self, argv): try: @@ -350,12 +351,12 @@ class InstanceNuxwdogEnableCLI(pki.cli.CLI): 'verbose', 'help']) except getopt.GetoptError as e: - print 'ERROR: ' + str(e) + print('ERROR: ' + str(e)) self.print_help() sys.exit(1) if len(args) != 1: - print 'ERROR: missing instance ID' + print('ERROR: missing instance ID') self.print_help() sys.exit(1) @@ -368,7 +369,7 @@ class InstanceNuxwdogEnableCLI(pki.cli.CLI): self.print_help() sys.exit() else: - print 'ERROR: unknown option ' + o + print('ERROR: unknown option ' + o) self.print_help() sys.exit(1) @@ -393,11 +394,11 @@ class InstanceNuxwdogDisableCLI(pki.cli.CLI): 'Instance disable nuxwdog') def print_help(self): - print 'Usage: pki-server instance-nuxwdog-disable [OPTIONS] <instance ID>' - print - print ' -v, --verbose Run in verbose mode.' - print ' --help Show help message.' - print + print('Usage: pki-server instance-nuxwdog-disable [OPTIONS] <instance ID>') + print() + print(' -v, --verbose Run in verbose mode.') + print(' --help Show help message.') + print() def execute(self, argv): try: @@ -405,12 +406,12 @@ class InstanceNuxwdogDisableCLI(pki.cli.CLI): 'verbose', 'help']) except getopt.GetoptError as e: - print 'ERROR: ' + str(e) + print('ERROR: ' + str(e)) self.print_help() sys.exit(1) if len(args) != 1: - print 'ERROR: missing instance ID' + print('ERROR: missing instance ID') self.print_help() sys.exit(1) @@ -423,7 +424,7 @@ class InstanceNuxwdogDisableCLI(pki.cli.CLI): self.print_help() sys.exit() else: - print 'ERROR: unknown option ' + o + print('ERROR: unknown option ' + o) self.print_help() sys.exit(1) diff --git a/base/server/python/pki/server/cli/migrate.py b/base/server/python/pki/server/cli/migrate.py index 325462048..98330eff4 100644 --- a/base/server/python/pki/server/cli/migrate.py +++ b/base/server/python/pki/server/cli/migrate.py @@ -20,6 +20,7 @@ # from __future__ import absolute_import +from __future__ import print_function import getopt import os import sys @@ -38,13 +39,13 @@ class MigrateCLI(pki.cli.CLI): self.parser = etree.XMLParser(remove_blank_text=True) def print_help(self): - print 'Usage: pki-server migrate [OPTIONS]' - print - print ' --tomcat <version> Use the specified Tomcat version.' - print ' -v, --verbose Run in verbose mode.' - print ' --debug Show debug messages.' - print ' --help Show help message.' - print + print('Usage: pki-server migrate [OPTIONS]') + print() + print(' --tomcat <version> Use the specified Tomcat version.') + print(' -v, --verbose Run in verbose mode.') + print(' --debug Show debug messages.') + print(' --help Show help message.') + print() def execute(self, argv): try: @@ -52,7 +53,7 @@ class MigrateCLI(pki.cli.CLI): 'tomcat=', 'verbose', 'debug', 'help']) except getopt.GetoptError as e: - print 'ERROR: ' + str(e) + print('ERROR: ' + str(e)) self.print_help() sys.exit(1) @@ -74,12 +75,12 @@ class MigrateCLI(pki.cli.CLI): sys.exit() else: - print 'ERROR: unknown option ' + o + print('ERROR: unknown option ' + o) self.print_help() sys.exit(1) if not tomcat_version: - print 'ERROR: missing Tomcat version' + print('ERROR: missing Tomcat version') self.print_help() sys.exit(1) @@ -116,7 +117,7 @@ class MigrateCLI(pki.cli.CLI): def migrate_server_xml(self, filename, tomcat_version): if self.verbose: - print 'Migrating %s' % filename + print('Migrating %s' % filename) document = etree.parse(filename, self.parser) @@ -127,7 +128,7 @@ class MigrateCLI(pki.cli.CLI): self.migrate_server_xml_to_tomcat8(document) elif tomcat_version: - print 'ERROR: invalid Tomcat version %s' % tomcat_version + print('ERROR: invalid Tomcat version %s' % tomcat_version) self.print_help() sys.exit(1) @@ -188,7 +189,7 @@ class MigrateCLI(pki.cli.CLI): 'org.apache.catalina.core.JreMemoryLeakPreventionListener', 'org.apache.catalina.core.ThreadLocalLeakPreventionListener'}: if self.debug: - print '* removing %s' % class_name + print('* removing %s' % class_name) server.remove(child) elif class_name == 'org.apache.catalina.core.JasperListener': @@ -210,7 +211,7 @@ class MigrateCLI(pki.cli.CLI): if jasper_listener is not None: if self.debug: - print '* adding %s' % jasper_listener.get('className') + print('* adding %s' % jasper_listener.get('className')) server.insert(index, jasper_listener) index += 1 @@ -231,7 +232,7 @@ class MigrateCLI(pki.cli.CLI): index += 1 if self.debug: - print '* updating secure Connector' + print('* updating secure Connector') connectors = server.findall('Service/Connector') for connector in connectors: @@ -239,7 +240,7 @@ class MigrateCLI(pki.cli.CLI): connector.set('protocol', 'HTTP/1.1') if self.debug: - print '* updating AccessLogValve' + print('* updating AccessLogValve') valves = server.findall('Service/Engine/Host/Valve') for valve in valves: @@ -297,7 +298,7 @@ class MigrateCLI(pki.cli.CLI): if class_name == 'org.apache.catalina.core.JasperListener'\ or class_name == 'org.apache.catalina.mbeans.ServerLifecycleListener': if self.debug: - print '* removing %s' % class_name + print('* removing %s' % class_name) server.remove(child) elif class_name == 'org.apache.catalina.startup.VersionLoggerListener': version_logger_listener = None @@ -313,7 +314,7 @@ class MigrateCLI(pki.cli.CLI): if version_logger_listener is not None: if self.debug: - print '* adding VersionLoggerListener' + print('* adding VersionLoggerListener') server.insert(index, version_logger_listener) index += 1 @@ -331,7 +332,7 @@ class MigrateCLI(pki.cli.CLI): if jre_memory_leak_prevention_listener is not None: if self.debug: - print '* adding JreMemoryLeakPreventionListener' + print('* adding JreMemoryLeakPreventionListener') server.insert(index, jre_memory_leak_prevention_listener) index += 1 @@ -341,12 +342,12 @@ class MigrateCLI(pki.cli.CLI): if thread_local_leak_prevention_listener is not None: if self.debug: - print '* adding ThreadLocalLeakPreventionListener' + print('* adding ThreadLocalLeakPreventionListener') server.insert(index, thread_local_leak_prevention_listener) index += 1 if self.debug: - print '* updating secure Connector' + print('* updating secure Connector') connectors = server.findall('Service/Connector') for connector in connectors: @@ -357,7 +358,7 @@ class MigrateCLI(pki.cli.CLI): 'org.apache.coyote.http11.Http11Protocol') if self.debug: - print '* updating AccessLogValve' + print('* updating AccessLogValve') valves = server.findall('Service/Engine/Host/Valve') for valve in valves: @@ -378,7 +379,7 @@ class MigrateCLI(pki.cli.CLI): return if self.verbose: - print 'Migrating %s' % filename + print('Migrating %s' % filename) document = etree.parse(filename, self.parser) @@ -389,7 +390,7 @@ class MigrateCLI(pki.cli.CLI): self.migrate_context_xml_to_tomcat8(document) elif tomcat_version: - print 'ERROR: invalid Tomcat version %s' % tomcat_version + print('ERROR: invalid Tomcat version %s' % tomcat_version) self.print_help() sys.exit(1) @@ -405,7 +406,7 @@ class MigrateCLI(pki.cli.CLI): if resources is not None: if self.debug: - print '* removing Resources' + print('* removing Resources') context.remove(resources) @@ -419,7 +420,7 @@ class MigrateCLI(pki.cli.CLI): if resources is None: if self.debug: - print '* adding Resources' + print('* adding Resources') resources = etree.Element('Resources') context.append(resources) @@ -436,7 +437,7 @@ class MigrateCLI(pki.cli.CLI): path = os.path.join(instance.lib_dir, filename) if self.verbose: - print 'Removing %s' % path + print('Removing %s' % path) os.remove(path) @@ -452,7 +453,7 @@ class MigrateCLI(pki.cli.CLI): dest = os.path.join(instance.lib_dir, filename) if self.verbose: - print 'Creating %s' % dest + print('Creating %s' % dest) os.symlink(source, dest) os.lchown(dest, instance.uid, instance.gid) diff --git a/base/server/python/pki/server/cli/nuxwdog.py b/base/server/python/pki/server/cli/nuxwdog.py index 36ff3c5d5..674fc0340 100644 --- a/base/server/python/pki/server/cli/nuxwdog.py +++ b/base/server/python/pki/server/cli/nuxwdog.py @@ -20,6 +20,7 @@ # from __future__ import absolute_import +from __future__ import print_function import getopt import fileinput import os @@ -59,11 +60,11 @@ class NuxwdogEnableCLI(pki.cli.CLI): 'Enable nuxwdog') def print_help(self): - print 'Usage: pki-server nuxwdog-enable [OPTIONS]' - print - print ' -v, --verbose Run in verbose mode.' - print ' --help Show help message.' - print + print('Usage: pki-server nuxwdog-enable [OPTIONS]') + print() + print(' -v, --verbose Run in verbose mode.') + print(' --help Show help message.') + print() def execute(self, argv): try: @@ -71,7 +72,7 @@ class NuxwdogEnableCLI(pki.cli.CLI): 'verbose', 'help']) except getopt.GetoptError as e: - print 'ERROR: ' + str(e) + print('ERROR: ' + str(e)) self.print_help() sys.exit(1) @@ -84,7 +85,7 @@ class NuxwdogEnableCLI(pki.cli.CLI): sys.exit() else: - print 'ERROR: unknown option ' + o + print('ERROR: unknown option ' + o) self.print_help() sys.exit(1) @@ -172,7 +173,7 @@ class NuxwdogEnableCLI(pki.cli.CLI): def enable_nuxwdog_server_xml(self, filename, instance): if self.verbose: - print 'Enabling nuxwdog in %s' % filename + print('Enabling nuxwdog in %s' % filename) conf_file = self.get_conf_file(instance) @@ -265,11 +266,11 @@ class NuxwdogDisableCLI(pki.cli.CLI): 'Disable nuxwdog') def print_help(self): - print 'Usage: pki-server nuxwdog-disable [OPTIONS]' - print - print ' -v, --verbose Run in verbose mode.' - print ' --help Show help message.' - print + print('Usage: pki-server nuxwdog-disable [OPTIONS]') + print() + print(' -v, --verbose Run in verbose mode.') + print(' --help Show help message.') + print() def execute(self, argv): try: @@ -277,7 +278,7 @@ class NuxwdogDisableCLI(pki.cli.CLI): 'verbose', 'help']) except getopt.GetoptError as e: - print 'ERROR: ' + str(e) + print('ERROR: ' + str(e)) self.print_help() sys.exit(1) @@ -290,7 +291,7 @@ class NuxwdogDisableCLI(pki.cli.CLI): sys.exit() else: - print 'ERROR: unknown option ' + o + print('ERROR: unknown option ' + o) self.print_help() sys.exit(1) @@ -351,7 +352,7 @@ class NuxwdogDisableCLI(pki.cli.CLI): def disable_nuxwdog_server_xml(self, filename, instance): if self.verbose: - print 'Disabling nuxwdog in %s' % filename + print('Disabling nuxwdog in %s' % filename) pw_conf = os.path.join(instance.conf_dir, 'password.conf') diff --git a/base/server/python/pki/server/cli/subsystem.py b/base/server/python/pki/server/cli/subsystem.py index 2f1e7e2f8..b1c20af59 100644 --- a/base/server/python/pki/server/cli/subsystem.py +++ b/base/server/python/pki/server/cli/subsystem.py @@ -20,6 +20,7 @@ # from __future__ import absolute_import +from __future__ import print_function import getopt import os import sys @@ -41,9 +42,9 @@ class SubsystemCLI(pki.cli.CLI): @staticmethod def print_subsystem(subsystem): - print ' Subsystem ID: %s' % subsystem.name - print ' Instance ID: %s' % subsystem.instance.name - print ' Enabled: %s' % subsystem.is_enabled() + print(' Subsystem ID: %s' % subsystem.name) + print(' Instance ID: %s' % subsystem.instance.name) + print(' Enabled: %s' % subsystem.is_enabled()) class SubsystemFindCLI(pki.cli.CLI): @@ -52,12 +53,12 @@ class SubsystemFindCLI(pki.cli.CLI): super(SubsystemFindCLI, self).__init__('find', 'Find subsystems') def usage(self): - print 'Usage: pki-server subsystem-find [OPTIONS]' - print - print ' -i, --instance <instance ID> Instance ID.' - print ' -v, --verbose Run in verbose mode.' - print ' --help Show help message.' - print + print('Usage: pki-server subsystem-find [OPTIONS]') + print() + print(' -i, --instance <instance ID> Instance ID.') + print(' -v, --verbose Run in verbose mode.') + print(' --help Show help message.') + print() def execute(self, args): @@ -67,7 +68,7 @@ class SubsystemFindCLI(pki.cli.CLI): 'verbose', 'help']) except getopt.GetoptError as e: - print 'ERROR: ' + str(e) + print('ERROR: ' + str(e)) self.usage() sys.exit(1) @@ -85,12 +86,12 @@ class SubsystemFindCLI(pki.cli.CLI): sys.exit() else: - print 'ERROR: unknown option ' + o + print('ERROR: unknown option ' + o) self.usage() sys.exit(1) if not instance_name: - print 'ERROR: missing instance ID' + print('ERROR: missing instance ID') self.usage() sys.exit(1) @@ -114,7 +115,7 @@ class SubsystemFindCLI(pki.cli.CLI): if first: first = False else: - print + print() SubsystemCLI.print_subsystem(subsystem) @@ -125,12 +126,12 @@ class SubsystemShowCLI(pki.cli.CLI): super(SubsystemShowCLI, self).__init__('show', 'Show subsystem') def usage(self): - print 'Usage: pki-server subsystem-show [OPTIONS] <subsystem ID>' - print - print ' -i, --instance <instance ID> Instance ID.' - print ' -v, --verbose Run in verbose mode.' - print ' --help Show help message.' - print + print('Usage: pki-server subsystem-show [OPTIONS] <subsystem ID>') + print() + print(' -i, --instance <instance ID> Instance ID.') + print(' -v, --verbose Run in verbose mode.') + print(' --help Show help message.') + print() def execute(self, argv): @@ -140,12 +141,12 @@ class SubsystemShowCLI(pki.cli.CLI): 'verbose', 'help']) except getopt.GetoptError as e: - print 'ERROR: ' + str(e) + print('ERROR: ' + str(e)) self.usage() sys.exit(1) if len(args) != 1: - print 'ERROR: missing subsystem ID' + print('ERROR: missing subsystem ID') self.usage() sys.exit(1) @@ -164,12 +165,12 @@ class SubsystemShowCLI(pki.cli.CLI): sys.exit() else: - print 'ERROR: unknown option ' + o + print('ERROR: unknown option ' + o) self.usage() sys.exit(1) if not instance_name: - print 'ERROR: missing instance ID' + print('ERROR: missing instance ID') self.usage() sys.exit(1) @@ -187,12 +188,12 @@ class SubsystemEnableCLI(pki.cli.CLI): super(SubsystemEnableCLI, self).__init__('enable', 'Enable subsystem') def usage(self): - print 'Usage: pki-server subsystem-enable [OPTIONS] <subsystem ID>' - print - print ' -i, --instance <instance ID> Instance ID.' - print ' -v, --verbose Run in verbose mode.' - print ' --help Show help message.' - print + print('Usage: pki-server subsystem-enable [OPTIONS] <subsystem ID>') + print() + print(' -i, --instance <instance ID> Instance ID.') + print(' -v, --verbose Run in verbose mode.') + print(' --help Show help message.') + print() def execute(self, argv): @@ -202,12 +203,12 @@ class SubsystemEnableCLI(pki.cli.CLI): 'verbose', 'help']) except getopt.GetoptError as e: - print 'ERROR: ' + str(e) + print('ERROR: ' + str(e)) self.usage() sys.exit(1) if len(args) != 1: - print 'ERROR: missing subsystem ID' + print('ERROR: missing subsystem ID') self.usage() sys.exit(1) @@ -226,12 +227,12 @@ class SubsystemEnableCLI(pki.cli.CLI): sys.exit() else: - print 'ERROR: unknown option ' + o + print('ERROR: unknown option ' + o) self.usage() sys.exit(1) if not instance_name: - print 'ERROR: missing instance ID' + print('ERROR: missing instance ID') self.usage() sys.exit(1) @@ -254,12 +255,12 @@ class SubsystemDisableCLI(pki.cli.CLI): 'Disable subsystem') def usage(self): - print 'Usage: pki-server subsystem-disable [OPTIONS] <subsystem ID>' - print - print ' -i, --instance <instance ID> Instance ID.' - print ' -v, --verbose Run in verbose mode.' - print ' --help Show help message.' - print + print('Usage: pki-server subsystem-disable [OPTIONS] <subsystem ID>') + print() + print(' -i, --instance <instance ID> Instance ID.') + print(' -v, --verbose Run in verbose mode.') + print(' --help Show help message.') + print() def execute(self, argv): @@ -269,12 +270,12 @@ class SubsystemDisableCLI(pki.cli.CLI): 'verbose', 'help']) except getopt.GetoptError as e: - print 'ERROR: ' + str(e) + print('ERROR: ' + str(e)) self.usage() sys.exit(1) if len(args) != 1: - print 'ERROR: missing subsystem ID' + print('ERROR: missing subsystem ID') self.usage() sys.exit(1) @@ -293,12 +294,12 @@ class SubsystemDisableCLI(pki.cli.CLI): sys.exit() else: - print 'ERROR: unknown option ' + o + print('ERROR: unknown option ' + o) self.usage() sys.exit(1) if not instance_name: - print 'ERROR: missing instance ID' + print('ERROR: missing instance ID') self.usage() sys.exit(1) diff --git a/base/server/python/pki/server/deployment/pkiconfig.py b/base/server/python/pki/server/deployment/pkiconfig.py index 8bca657de..c22698cb6 100644 --- a/base/server/python/pki/server/deployment/pkiconfig.py +++ b/base/server/python/pki/server/deployment/pkiconfig.py @@ -20,6 +20,7 @@ # # PKI Deployment Constants +from __future__ import print_function PKI_DEPLOYMENT_DEFAULT_CLIENT_DIR_PERMISSIONS = 0o0755 PKI_DEPLOYMENT_DEFAULT_DIR_PERMISSIONS = 0o0770 PKI_DEPLOYMENT_DEFAULT_EXE_PERMISSIONS = 0o0770 @@ -127,38 +128,38 @@ def str2bool(string): # 'pki_enable_java_debugger=True' in the appropriate # deployment configuration file. def prepare_for_an_external_java_debugger(instance): - print - print PKI_DEPLOYMENT_INTERRUPT_BANNER - print - print "The following 'JAVA_OPTS' MUST be edited in" - print "'%s':" % instance - print - print " JAVA_OPTS=\"-DRESTEASY_LIB=/usr/share/java/resteasy \"" - print " \"-Xdebug -Xrunjdwp:transport=dt_socket,\"" - print " \"address=8000,server=y,suspend=n \"" - print " \"-Djava.awt.headless=true -Xmx128M\"" - print + print() + print(PKI_DEPLOYMENT_INTERRUPT_BANNER) + print() + print("The following 'JAVA_OPTS' MUST be edited in") + print("'%s':" % instance) + print() + print(" JAVA_OPTS=\"-DRESTEASY_LIB=/usr/share/java/resteasy \"") + print(" \"-Xdebug -Xrunjdwp:transport=dt_socket,\"") + 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 . . . ") - print - print PKI_DEPLOYMENT_INTERRUPT_BANNER - print + print() + print(PKI_DEPLOYMENT_INTERRUPT_BANNER) + print() return def wait_to_attach_an_external_java_debugger(): - print - print PKI_DEPLOYMENT_INTERRUPT_BANNER - print - print "Attach the java debugger to this process on the port specified by" - print "the 'address' selected by 'JAVA_OPTS' (e. g. - port 8000) and" - print "set any desired breakpoints" - print + print() + print(PKI_DEPLOYMENT_INTERRUPT_BANNER) + print() + print("Attach the java debugger to this process on the port specified by") + 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 . . . ") - print - print PKI_DEPLOYMENT_INTERRUPT_BANNER - print + print() + print(PKI_DEPLOYMENT_INTERRUPT_BANNER) + print() return diff --git a/base/server/python/pki/server/deployment/pkihelper.py b/base/server/python/pki/server/deployment/pkihelper.py index 589da5c74..de3b1bc55 100644 --- a/base/server/python/pki/server/deployment/pkihelper.py +++ b/base/server/python/pki/server/deployment/pkihelper.py @@ -22,6 +22,7 @@ # System Imports from __future__ import absolute_import +from __future__ import print_function import errno import sys import os @@ -4455,7 +4456,7 @@ class ConfigClient: data.adminCertRequest = b64 else: - print "log.PKI_CONFIG_PKCS10_SUPPORT_ONLY" + print("log.PKI_CONFIG_PKCS10_SUPPORT_ONLY") raise Exception(log.PKI_CONFIG_PKCS10_SUPPORT_ONLY) def set_issuing_ca_parameters(self, data): diff --git a/base/server/python/pki/server/deployment/pkimanifest.py b/base/server/python/pki/server/deployment/pkimanifest.py index d959efb4a..09c9ac668 100644 --- a/base/server/python/pki/server/deployment/pkimanifest.py +++ b/base/server/python/pki/server/deployment/pkimanifest.py @@ -21,6 +21,7 @@ # System Imports from __future__ import absolute_import +from __future__ import print_function import csv # PKI Deployment Imports @@ -97,7 +98,7 @@ class File: with open(self.filename, "r") as fd: cr = csv.reader(fd) for row in cr: - print tuple(row) + print(tuple(row)) except IOError as exc: config.pki_log.error(log.PKI_IOERROR_1, exc, extra=config.PKI_INDENTATION_LEVEL_1) diff --git a/base/server/python/pki/server/deployment/pkiparser.py b/base/server/python/pki/server/deployment/pkiparser.py index 08815a6b1..84e14bfec 100644 --- a/base/server/python/pki/server/deployment/pkiparser.py +++ b/base/server/python/pki/server/deployment/pkiparser.py @@ -21,6 +21,7 @@ # System Imports from __future__ import absolute_import +from __future__ import print_function import ConfigParser import argparse import getpass @@ -136,20 +137,20 @@ class PKIConfigParser: if len(config.pki_root_prefix) > 0: if not os.path.exists(config.pki_root_prefix) or \ not os.path.isdir(config.pki_root_prefix): - print "ERROR: " + \ - log.PKI_DIRECTORY_MISSING_OR_NOT_A_DIRECTORY_1 % \ - config.pki_root_prefix - print + print("ERROR: " + + log.PKI_DIRECTORY_MISSING_OR_NOT_A_DIRECTORY_1 % + config.pki_root_prefix) + print() self.arg_parser.print_help() self.arg_parser.exit(-1) # always default that configuration file exists if not os.path.exists(config.default_deployment_cfg) or \ not os.path.isfile(config.default_deployment_cfg): - print "ERROR: " + \ - log.PKI_FILE_MISSING_OR_NOT_A_FILE_1 % \ - config.default_deployment_cfg - print + print("ERROR: " + + log.PKI_FILE_MISSING_OR_NOT_A_FILE_1 % + config.default_deployment_cfg) + print() self.arg_parser.print_help() self.arg_parser.exit(-1) @@ -157,10 +158,10 @@ class PKIConfigParser: # verify user configuration file exists if not os.path.exists(config.user_deployment_cfg) or \ not os.path.isfile(config.user_deployment_cfg): - print "ERROR: " + \ - log.PKI_FILE_MISSING_OR_NOT_A_FILE_1 % \ - config.user_deployment_cfg - print + print("ERROR: " + + log.PKI_FILE_MISSING_OR_NOT_A_FILE_1 % + config.user_deployment_cfg) + print() self.arg_parser.print_help() self.arg_parser.exit(-1) @@ -247,7 +248,7 @@ class PKIConfigParser: config.user_config.set(section, key, value) def print_text(self, message): - print ' ' * self.indent + message + print(' ' * self.indent + message) def read_text(self, message, section=None, key=None, default=None, options=None, sign=':', allow_empty=True, @@ -337,8 +338,8 @@ class PKIConfigParser: 'pki_replicationdb_password', 'pki_security_domain_password') - print 'Loading deployment configuration from ' + \ - config.user_deployment_cfg + '.' + print('Loading deployment configuration from ' + + config.user_deployment_cfg + '.') self.pki_config.read([config.user_deployment_cfg]) config.user_config.read([config.user_deployment_cfg]) @@ -372,7 +373,7 @@ class PKIConfigParser: except ConfigParser.NoOptionError: continue except ConfigParser.ParsingError as err: - print err + print(err) rv = err return rv diff --git a/base/server/python/pki/server/deployment/scriptlets/infrastructure_layout.py b/base/server/python/pki/server/deployment/scriptlets/infrastructure_layout.py index 365bfb763..f7ef82825 100644 --- a/base/server/python/pki/server/deployment/scriptlets/infrastructure_layout.py +++ b/base/server/python/pki/server/deployment/scriptlets/infrastructure_layout.py @@ -22,6 +22,7 @@ from __future__ import absolute_import # PKI Deployment Imports +from __future__ import print_function from .. import pkiconfig as config from .. import pkimessages as log from .. import pkiscriptlet @@ -63,8 +64,8 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet): deployer.mdict['pki_default_deployment_cfg'], deployer.mdict['pki_default_deployment_cfg_replica']) - print "Storing deployment configuration into " + \ - deployer.mdict['pki_user_deployment_cfg_replica'] + "." + print("Storing deployment configuration into " + + deployer.mdict['pki_user_deployment_cfg_replica'] + ".") # Archive the user deployment configuration excluding the sensitive # parameters diff --git a/base/server/python/pki/server/upgrade.py b/base/server/python/pki/server/upgrade.py index cc9db48e4..a0e52b22b 100644 --- a/base/server/python/pki/server/upgrade.py +++ b/base/server/python/pki/server/upgrade.py @@ -20,6 +20,7 @@ # from __future__ import absolute_import +from __future__ import print_function import os import traceback @@ -78,12 +79,12 @@ class PKIServerUpgradeScriptlet(pki.upgrade.PKIUpgradeScriptlet): if not self.can_upgrade_server(instance): if verbose: - print 'Skipping ' + str(instance) + ' instance.' + print('Skipping ' + str(instance) + ' instance.') continue try: if verbose: - print 'Upgrading ' + str(instance) + ' instance.' + print('Upgrading ' + str(instance) + ' instance.') self.upgrade_instance(instance) self.update_server_tracker(instance) @@ -92,11 +93,11 @@ class PKIServerUpgradeScriptlet(pki.upgrade.PKIUpgradeScriptlet): if verbose: traceback.print_exc() else: - print 'ERROR: %s' % e + print('ERROR: %s' % e) message = 'Failed upgrading ' + str(instance) + ' instance.' if self.upgrader.silent: - print message + print(message) else: result = pki.read_text( message + ' Continue (Yes/No)', @@ -113,12 +114,12 @@ class PKIServerUpgradeScriptlet(pki.upgrade.PKIUpgradeScriptlet): if not self.can_upgrade_server(instance, subsystem): if verbose: - print 'Skipping ' + str(subsystem) + ' subsystem.' + print('Skipping ' + str(subsystem) + ' subsystem.') continue try: if verbose: - print 'Upgrading ' + str(subsystem) + ' subsystem.' + print('Upgrading ' + str(subsystem) + ' subsystem.') self.upgrade_subsystem(instance, subsystem) self.update_server_tracker(instance, subsystem) @@ -127,11 +128,11 @@ class PKIServerUpgradeScriptlet(pki.upgrade.PKIUpgradeScriptlet): if verbose: traceback.print_exc() else: - print 'ERROR: %s' % e + print('ERROR: %s' % e) message = 'Failed upgrading ' + str(subsystem) + ' subsystem.' if self.upgrader.silent: - print message + print(message) else: result = pki.read_text( message + ' Continue (Yes/No)', @@ -326,7 +327,7 @@ class PKIServerUpgrader(pki.upgrade.PKIUpgrader): tracker = self.get_server_tracker(instance, subsystem) tracker.set(version) - print 'Tracker has been set to version ' + str(version) + '.' + print('Tracker has been set to version ' + str(version) + '.') def remove_tracker(self): for instance in self.instances(): @@ -340,4 +341,4 @@ class PKIServerUpgrader(pki.upgrade.PKIUpgrader): tracker = self.get_server_tracker(instance, subsystem) tracker.remove() - print 'Tracker has been removed.' + print('Tracker has been removed.') |