py3: ConfigParser: replace deprecated readfd with read

ConfigParser.readfd() is deprecated in py3, we can use .read() which is
compatible with py2

https://fedorahosted.org/freeipa/ticket/4985

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
This commit is contained in:
Martin Basti 2017-05-30 13:41:56 +02:00
parent 2e63ec42d0
commit 6e7071d6ad
2 changed files with 4 additions and 6 deletions

View File

@ -749,10 +749,9 @@ def read_replica_info(dir_path, rconfig):
rconfig is a ReplicaConfig object rconfig is a ReplicaConfig object
""" """
filename = dir_path + "/realm_info" filename = os.path.join(dir_path, "realm_info")
fd = open(filename)
config = SafeConfigParser() config = SafeConfigParser()
config.readfp(fd) config.read(filename)
rconfig.realm_name = config.get("realm", "realm_name") rconfig.realm_name = config.get("realm", "realm_name")
rconfig.master_host_name = config.get("realm", "master_host_name") rconfig.master_host_name = config.get("realm", "master_host_name")

View File

@ -711,9 +711,8 @@ class Restore(admintool.AdminTool):
Read the backup file header that contains the meta data about Read the backup file header that contains the meta data about
this particular backup. this particular backup.
''' '''
with open(self.header) as fd: config = SafeConfigParser()
config = SafeConfigParser() config.read(self.header)
config.readfp(fd)
self.backup_type = config.get('ipa', 'type') self.backup_type = config.get('ipa', 'type')
self.backup_time = config.get('ipa', 'time') self.backup_time = config.get('ipa', 'time')