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
* silence import error in Azure script
* silence too-many-function-args

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 598770c
Show file tree
Hide file tree
Showing 6 changed files with 22 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
2 changes: 1 addition & 1 deletion ipatests/azure/scripts/setup_containers.py
Expand Up @@ -2,7 +2,7 @@
import os
import subprocess

import docker
import docker # pylint: disable=import-error
from jinja2 import Template

logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s')
Expand Down
2 changes: 2 additions & 0 deletions pylintrc
Expand Up @@ -102,6 +102,8 @@ 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
too-many-function-args, # pylint 2.5.0, should be fixed

[REPORTS]

Expand Down

0 comments on commit 598770c

Please sign in to comment.