summaryrefslogtreecommitdiffstats
path: root/ipa-client/ipa-install
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2015-08-12 13:44:11 +0200
committerJan Cholasta <jcholast@redhat.com>2015-09-01 11:42:01 +0200
commit8de13bd7dd76f5f5b23d6e4fb84be1a2f1dc5c5e (patch)
treeac6435b79d3e540e907bcc88e3b1c534c2945626 /ipa-client/ipa-install
parentfb7943dab454f358316160b4baf99075603a162d (diff)
downloadfreeipa-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 'ipa-client/ipa-install')
-rwxr-xr-xipa-client/ipa-install/ipa-client-automount52
-rwxr-xr-xipa-client/ipa-install/ipa-client-install22
2 files changed, 39 insertions, 35 deletions
diff --git a/ipa-client/ipa-install/ipa-client-automount b/ipa-client/ipa-install/ipa-client-automount
index 4abc853dc..5cac122c2 100755
--- a/ipa-client/ipa-install/ipa-client-automount
+++ b/ipa-client/ipa-install/ipa-client-automount
@@ -21,6 +21,8 @@
#
# Configure the automount client for ldap.
+from __future__ import print_function
+
import sys
import os
import urlparse
@@ -86,8 +88,8 @@ def wait_for_sssd():
err_msg = ("Unable to find 'admin' user with "
"'getent passwd admin@%s'!" % api.env.realm)
root_logger.debug(err_msg)
- print err_msg
- print "This may mean that sssd didn't re-start properly after the configuration changes."
+ print(err_msg)
+ print("This may mean that sssd didn't re-start properly after the configuration changes.")
def configure_xml(fstore):
from lxml import etree
@@ -122,8 +124,8 @@ def configure_xml(fstore):
root.write(newconf, pretty_print=True, xml_declaration=True, encoding='UTF-8')
newconf.close()
except IOError as e:
- print "Unable to write %s: %s" % (paths.AUTOFS_LDAP_AUTH_CONF, e)
- print "Configured %s" % paths.AUTOFS_LDAP_AUTH_CONF
+ print("Unable to write %s: %s" % (paths.AUTOFS_LDAP_AUTH_CONF, e))
+ print("Configured %s" % paths.AUTOFS_LDAP_AUTH_CONF)
def configure_nsswitch(fstore, options):
"""
@@ -142,7 +144,7 @@ def configure_nsswitch(fstore, options):
conf.changeConf(paths.NSSWITCH_CONF, opts)
- print "Configured %s" % paths.NSSWITCH_CONF
+ print("Configured %s" % paths.NSSWITCH_CONF)
def configure_autofs_sssd(fstore, statestore, autodiscover, options):
try:
@@ -191,7 +193,7 @@ def configure_autofs_sssd(fstore, statestore, autodiscover, options):
sssd = services.service('sssd')
sssd.restart()
- print "Restarting sssd, waiting for it to become available."
+ print("Restarting sssd, waiting for it to become available.")
wait_for_sssd()
def configure_autofs(fstore, statestore, autodiscover, server, options):
@@ -221,7 +223,7 @@ def configure_autofs(fstore, statestore, autodiscover, server, options):
tasks.restore_context(paths.SYSCONFIG_AUTOFS)
statestore.backup_state('autofs', 'sssd', False)
- print "Configured %s" % paths.SYSCONFIG_AUTOFS
+ print("Configured %s" % paths.SYSCONFIG_AUTOFS)
def configure_autofs_common(fstore, statestore, options):
autofs = services.knownservices.autofs
@@ -229,17 +231,17 @@ def configure_autofs_common(fstore, statestore, options):
statestore.backup_state('autofs', 'running', autofs.is_running())
try:
autofs.restart()
- print "Started %s" % autofs.service_name
+ print("Started %s" % autofs.service_name)
except Exception as e:
root_logger.error("%s failed to restart: %s", autofs.service_name, e)
try:
autofs.enable()
except Exception as e:
- print "Failed to configure automatic startup of the %s daemon" % (autofs.service_name)
+ print("Failed to configure automatic startup of the %s daemon" % (autofs.service_name))
root_logger.error("Failed to enable automatic startup of the %s daemon: %s" % (autofs.service_name, str(e)))
def uninstall(fstore, statestore):
- print "Restoring configuration"
+ print("Restoring configuration")
if fstore.has_file(paths.SYSCONFIG_AUTOFS):
fstore.restore_file(paths.SYSCONFIG_AUTOFS)
if fstore.has_file(paths.NSSWITCH_CONF):
@@ -281,7 +283,7 @@ def uninstall(fstore, statestore):
sssd.restart()
wait_for_sssd()
except Exception as e:
- print 'Unable to restore SSSD configuration: %s' % str(e)
+ print('Unable to restore SSSD configuration: %s' % str(e))
root_logger.debug('Unable to restore SSSD configuration: %s' % str(e))
if statestore.has_state('rpcidmapd'):
enabled = statestore.restore_state('rpcidmapd', 'enabled')
@@ -313,7 +315,7 @@ def configure_nfs(fstore, statestore):
paths.SYSCONFIG_NFS, replacevars=replacevars)
tasks.restore_context(paths.SYSCONFIG_NFS)
- print "Configured %s" % paths.SYSCONFIG_NFS
+ print("Configured %s" % paths.SYSCONFIG_NFS)
replacevars = {
'Domain': api.env.domain,
@@ -322,20 +324,20 @@ def configure_nfs(fstore, statestore):
paths.IDMAPD_CONF, replacevars=replacevars)
tasks.restore_context(paths.IDMAPD_CONF)
- print "Configured %s" % paths.IDMAPD_CONF
+ print("Configured %s" % paths.IDMAPD_CONF)
rpcidmapd = services.knownservices.rpcidmapd
statestore.backup_state('rpcidmapd', 'enabled', rpcidmapd.is_enabled())
statestore.backup_state('rpcidmapd', 'running', rpcidmapd.is_running())
try:
rpcidmapd.restart()
- print "Started %s" % rpcidmapd.service_name
+ print("Started %s" % rpcidmapd.service_name)
except Exception as e:
root_logger.error("%s failed to restart: %s", rpcidmapd.service_name, e)
try:
rpcidmapd.enable()
except Exception as e:
- print "Failed to configure automatic startup of the %s daemon" % (rpcidmapd.service_name)
+ print("Failed to configure automatic startup of the %s daemon" % (rpcidmapd.service_name))
root_logger.error("Failed to enable automatic startup of the %s daemon: %s" % (rpcidmapd.service_name, str(e)))
rpcgssd = services.knownservices.rpcgssd
@@ -343,13 +345,13 @@ def configure_nfs(fstore, statestore):
statestore.backup_state('rpcgssd', 'running', rpcgssd.is_running())
try:
rpcgssd.restart()
- print "Started %s" % rpcgssd.service_name
+ print("Started %s" % rpcgssd.service_name)
except Exception as e:
root_logger.error("%s failed to restart: %s", rpcgssd.service_name, e)
try:
rpcgssd.enable()
except Exception as e:
- print "Failed to configure automatic startup of the %s daemon" % (rpcgssd.service_name)
+ print("Failed to configure automatic startup of the %s daemon" % (rpcgssd.service_name))
root_logger.error("Failed to enable automatic startup of the %s daemon: %s" % (rpcgssd.service_name, str(e)))
def main():
@@ -389,7 +391,7 @@ def main():
servers = []
ds = ipadiscovery.IPADiscovery()
if not options.server:
- print "Searching for IPA server..."
+ print("Searching for IPA server...")
ret = ds.search(ca_cert_path=ca_cert_path)
root_logger.debug('Executing DNS discovery')
if ret == ipadiscovery.NO_LDAP_SERVER:
@@ -408,23 +410,23 @@ def main():
root_logger.debug("Verifying that %s is an IPA server" % server)
ldapret = ds.ipacheckldap(server, api.env.realm, ca_cert_path)
if ldapret[0] == ipadiscovery.NO_ACCESS_TO_LDAP:
- print "Anonymous access to the LDAP server is disabled."
- print "Proceeding without strict verification."
- print "Note: This is not an error if anonymous access has been explicitly restricted."
+ print("Anonymous access to the LDAP server is disabled.")
+ print("Proceeding without strict verification.")
+ print("Note: This is not an error if anonymous access has been explicitly restricted.")
elif ldapret[0] == ipadiscovery.NO_TLS_LDAP:
root_logger.warning("Unencrypted access to LDAP is not supported.")
elif ldapret[0] != 0:
sys.exit('Unable to confirm that %s is an IPA server' % server)
if not autodiscover:
- print "IPA server: %s" % server
+ print("IPA server: %s" % server)
root_logger.debug('Using fixed server %s' % server)
else:
- print "IPA server: DNS discovery"
+ print("IPA server: DNS discovery")
root_logger.debug('Configuring to use DNS discovery')
search_base = str(DN(('cn', options.location), api.env.container_automount, api.env.basedn))
- print "Location: %s" % options.location
+ print("Location: %s" % options.location)
root_logger.debug('Using automount location %s' % options.location)
ccache_dir = tempfile.mkdtemp()
@@ -473,7 +475,7 @@ def main():
configure_autofs_common(fstore, statestore, options)
except Exception as e:
root_logger.debug('Raised exception %s' % e)
- print "Installation failed. Rolling back changes."
+ print("Installation failed. Rolling back changes.")
uninstall(fstore, statestore)
return 1
diff --git a/ipa-client/ipa-install/ipa-client-install b/ipa-client/ipa-install/ipa-client-install
index b6e6fa02e..f6cf2c027 100755
--- a/ipa-client/ipa-install/ipa-client-install
+++ b/ipa-client/ipa-install/ipa-client-install
@@ -19,6 +19,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+from __future__ import print_function
+
try:
import sys
@@ -58,12 +60,12 @@ try:
from ipalib.rpc import delete_persistent_client_session_data
except ImportError as e:
- print >> sys.stderr, """\
+ print("""\
There was a problem importing one of the required Python modules. The
error was:
%s
-""" % e
+""" % e, file=sys.stderr)
sys.exit(1)
SUCCESS = 0
@@ -2226,12 +2228,12 @@ def install(options, env, fstore, statestore):
try:
ipaclient.ntpconf.check_timedate_services()
except ipaclient.ntpconf.NTPConflictingService as e:
- print "WARNING: ntpd time&date synchronization service will not" \
- " be configured as"
- print "conflicting service (%s) is enabled" % e.conflicting_service
- print "Use --force-ntpd option to disable it and force configuration" \
- " of ntpd"
- print ""
+ print("WARNING: ntpd time&date synchronization service will not" \
+ " be configured as")
+ print("conflicting service (%s) is enabled" % e.conflicting_service)
+ print("Use --force-ntpd option to disable it and force configuration" \
+ " of ntpd")
+ print("")
# configuration of ntpd is disabled in this case
options.conf_ntp = False
@@ -2475,13 +2477,13 @@ def install(options, env, fstore, statestore):
is_ipaddr = False
if is_ipaddr:
- print
+ print()
root_logger.warning("It seems that you are using an IP address "
"instead of FQDN as an argument to --server. The "
"installation may fail.")
break
- print
+ print()
if not options.unattended and not user_input("Continue to configure the system with these values?", False):
return CLIENT_INSTALL_ERROR