Skip to content

Commit

Permalink
Address issues found by new pylint 2.5.0
Browse files Browse the repository at this point in the history
* fix multiple exception-escape
* fix function signatures of DsInstance start/stop/restart
* silence f-string-without-interpolation
* fix too-many-function-args in host plugin

Fixes: https://pagure.io/freeipa/issue/8297
Signed-off-by: Christian Heimes <cheimes@redhat.com>
  • Loading branch information
tiran committed Apr 28, 2020
1 parent c2608cf commit 6ba8777
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
4 changes: 2 additions & 2 deletions ipaclient/install/client.py
Expand Up @@ -1901,9 +1901,9 @@ def http_url():
if os.path.exists(ca_file):
try:
os.unlink(ca_file)
except OSError as e:
except OSError as e2:
logger.error(
"Failed to remove '%s': %s", ca_file, e)
"Failed to remove '%s': %s", ca_file, e2)
raise errors.FileError(
reason=u"cannot write certificate file '%s': %s" % (
ca_file, e)
Expand Down
20 changes: 13 additions & 7 deletions ipaserver/install/dsinstance.py
Expand Up @@ -652,21 +652,27 @@ def __add_default_schemas(self):
# Does not apply with newer DS releases
pass

def start(self, *args, **kwargs):
super(DsInstance, self).start(*args, **kwargs)
def start(self, instance_name="", capture_output=True, wait=True):
super(DsInstance, self).start(
instance_name, capture_output=capture_output, wait=wait
)
api.Backend.ldap2.connect()

def stop(self, *args, **kwargs):
def stop(self, instance_name="", capture_output=True):
if api.Backend.ldap2.isconnected():
api.Backend.ldap2.disconnect()

super(DsInstance, self).stop(*args, **kwargs)
super(DsInstance, self).stop(
instance_name, capture_output=capture_output
)

def restart(self, instance=''):
def restart(self, instance_name="", capture_output=True, wait=True):
api.Backend.ldap2.disconnect()
try:
super(DsInstance, self).restart(instance)
if not is_ds_running(instance):
super(DsInstance, self).restart(
instance_name, capture_output=capture_output, wait=wait
)
if not is_ds_running(instance_name):
logger.critical("Failed to restart the directory server. "
"See the installation log for details.")
raise ScriptError()
Expand Down
4 changes: 2 additions & 2 deletions ipaserver/install/server/upgrade.py
Expand Up @@ -352,8 +352,8 @@ def upgrade_adtrust_config():
"max smbd processes", "1000"]
try:
ipautil.run(args)
except ipautil.CalledProcessError as e:
logger.warning("Error updating Samba registry: %s", e)
except ipautil.CalledProcessError as e2:
logger.warning("Error updating Samba registry: %s", e2)
else:
logger.warning("Error updating Samba registry: %s", e)

Expand Down
4 changes: 2 additions & 2 deletions ipaserver/plugins/migration.py
Expand Up @@ -858,8 +858,8 @@ def migrate(self, ldap, config, ds_ldap, ds_base_dn, options):
try:
callback(
ldap, entry_attrs.dn, entry_attrs, e, options)
except errors.ExecutionError as e:
failed[ldap_obj_name][pkey] = unicode(e)
except errors.ExecutionError as e2:
failed[ldap_obj_name][pkey] = unicode(e2)
continue
else:
failed[ldap_obj_name][pkey] = unicode(e)
Expand Down
8 changes: 7 additions & 1 deletion ipatests/pytest_ipa/integration/host.py
Expand Up @@ -134,7 +134,13 @@ def _make_host(domain, hostname, role, ip, external_hostname):
else:
cls = Host

return cls(domain, hostname, role, ip, external_hostname)
return cls(
domain,
hostname,
role,
ip=ip,
external_hostname=external_hostname
)

def ldap_connect(self):
"""Return an LDAPClient authenticated to this host as directory manager
Expand Down
1 change: 1 addition & 0 deletions pylintrc
Expand Up @@ -102,6 +102,7 @@ disable=
consider-using-enumerate, # pylint 2.1, clean up tests later
no-else-raise, # python 2.4.0
import-outside-toplevel, # pylint 2.4.2
f-string-without-interpolation, # pylint 2.5.0, bare f-strings are ok

[REPORTS]

Expand Down

0 comments on commit 6ba8777

Please sign in to comment.