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>
This commit is contained in:
Petr Viktorin
2015-08-12 13:44:11 +02:00
committed by Jan Cholasta
parent fb7943dab4
commit 8de13bd7dd
68 changed files with 954 additions and 838 deletions

View File

@@ -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)

View File

@@ -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):

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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()