diff options
author | Petr Viktorin <pviktori@redhat.com> | 2015-08-12 13:44:11 +0200 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2015-09-01 11:42:01 +0200 |
commit | 8de13bd7dd76f5f5b23d6e4fb84be1a2f1dc5c5e (patch) | |
tree | ac6435b79d3e540e907bcc88e3b1c534c2945626 /ipapython | |
parent | fb7943dab454f358316160b4baf99075603a162d (diff) | |
download | freeipa-8de13bd7dd76f5f5b23d6e4fb84be1a2f1dc5c5e.tar.gz freeipa-8de13bd7dd76f5f5b23d6e4fb84be1a2f1dc5c5e.tar.xz freeipa-8de13bd7dd76f5f5b23d6e4fb84be1a2f1dc5c5e.zip |
Use the print function
In Python 3, `print` is no longer a statement. Call it as a function
everywhere, and include the future import to remove the statement
in Python 2 code as well.
Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipapython')
-rw-r--r-- | ipapython/certmonger.py | 4 | ||||
-rw-r--r-- | ipapython/dn.py | 5 | ||||
-rwxr-xr-x | ipapython/dnssec/localhsm.py | 40 | ||||
-rw-r--r-- | ipapython/ipautil.py | 4 | ||||
-rw-r--r-- | ipapython/log_manager.py | 3 | ||||
-rw-r--r-- | ipapython/nsslib.py | 10 |
6 files changed, 38 insertions, 28 deletions
diff --git a/ipapython/certmonger.py b/ipapython/certmonger.py index 1371c215d..6ebec205a 100644 --- a/ipapython/certmonger.py +++ b/ipapython/certmonger.py @@ -22,6 +22,8 @@ # This is used so we can add tracking to the Apache and 389-ds # server certificates created during the IPA server installation. +from __future__ import print_function + import os import sys import time @@ -548,5 +550,5 @@ if __name__ == '__main__': "cn=tiger.example.com,O=IPA", "HTTP/tiger.example.com@EXAMPLE.COM") csr = get_request_value(request_id, 'csr') - print csr + print(csr) stop_tracking(request_id) diff --git a/ipapython/dn.py b/ipapython/dn.py index 640be72c3..a3b20121a 100644 --- a/ipapython/dn.py +++ b/ipapython/dn.py @@ -417,6 +417,7 @@ It is possible to "copy" an object by passing an object of the same type to the constructor. The result may share underlying structure. ''' +from __future__ import print_function import sys @@ -1121,8 +1122,8 @@ class DN(object): try: return dn2str(self.rdns) except Exception, e: - print len(self.rdns) - print self.rdns + print(len(self.rdns)) + print(self.rdns) raise def __repr__(self): diff --git a/ipapython/dnssec/localhsm.py b/ipapython/dnssec/localhsm.py index d3b4ae15c..2eab5c351 100755 --- a/ipapython/dnssec/localhsm.py +++ b/ipapython/dnssec/localhsm.py @@ -3,6 +3,8 @@ # Copyright (C) 2014 FreeIPA Contributors see COPYING for license # +from __future__ import print_function + from binascii import hexlify import collections import logging @@ -192,36 +194,36 @@ if __name__ == '__main__': localhsm = LocalHSM(paths.LIBSOFTHSM2_SO, 0, open(paths.DNSSEC_SOFTHSM_PIN).read()) - print 'replica public keys: CKA_WRAP = TRUE' - print '====================================' + print('replica public keys: CKA_WRAP = TRUE') + print('====================================') for pubkey_id, pubkey in localhsm.replica_pubkeys_wrap.items(): - print hexlify(pubkey_id) + print(hexlify(pubkey_id)) pprint(pubkey) - print '' - print 'replica public keys: all' - print '========================' + print('') + print('replica public keys: all') + print('========================') for pubkey_id, pubkey in localhsm.replica_pubkeys.items(): - print hexlify(pubkey_id) + print(hexlify(pubkey_id)) pprint(pubkey) - print '' - print 'master keys' - print '===========' + print('') + print('master keys') + print('===========') for mkey_id, mkey in localhsm.master_keys.items(): - print hexlify(mkey_id) + print(hexlify(mkey_id)) pprint(mkey) - print '' - print 'zone public keys' - print '================' + print('') + print('zone public keys') + print('================') for key_id, key in localhsm.zone_pubkeys.items(): - print hexlify(key_id) + print(hexlify(key_id)) pprint(key) - print '' - print 'zone private keys' - print '=================' + print('') + print('zone private keys') + print('=================') for key_id, key in localhsm.zone_privkeys.items(): - print hexlify(key_id) + print(hexlify(key_id)) pprint(key) diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 4cb3a96e6..80f79aac5 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import string import tempfile import subprocess @@ -1326,7 +1328,7 @@ def restore_hostname(statestore): try: run([paths.BIN_HOSTNAME, old_hostname]) except CalledProcessError as e: - print >>sys.stderr, "Failed to set this machine hostname back to %s: %s" % (old_hostname, str(e)) + print("Failed to set this machine hostname back to %s: %s" % (old_hostname, str(e)), file=sys.stderr) @contextmanager diff --git a/ipapython/log_manager.py b/ipapython/log_manager.py index e1ea434c5..bc9efc5de 100644 --- a/ipapython/log_manager.py +++ b/ipapython/log_manager.py @@ -500,6 +500,7 @@ bewildering difficult to get it do what I wanted. John Dennis <jdennis@redhat.com> ''' +from __future__ import print_function #------------------------------------------------------------------------------- import sys @@ -1242,7 +1243,7 @@ class LogManager(object): try: level = parse_log_level(level) except Exception as e: - print >>sys.stderr, 'could not set handler log level "%s" (%s)' % (level, e) + print('could not set handler log level "%s" (%s)' % (level, e), file=sys.stderr) level = None if level is None: level = self.default_level diff --git a/ipapython/nsslib.py b/ipapython/nsslib.py index 1fb69cbd1..da4521894 100644 --- a/ipapython/nsslib.py +++ b/ipapython/nsslib.py @@ -18,6 +18,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import sys import httplib import getpass @@ -340,9 +342,9 @@ if __name__ == "__main__": conn.connect() conn.request("GET", "/") response = conn.getresponse() - print response.status + print(response.status) #print response.msg - print response.getheaders() + print(response.getheaders()) data = response.read() #print data conn.close() @@ -353,8 +355,8 @@ if __name__ == "__main__": h.putrequest('GET', '/') h.endheaders() http_status, http_reason, headers = h.getreply() - print "status = %s %s" % (http_status, http_reason) - print "headers:\n%s" % headers + print("status = %s %s" % (http_status, http_reason)) + print("headers:\n%s" % headers) f = h.getfile() data = f.read() # Get the raw HTML f.close() |