removing try..except block

This commit is contained in:
Gareth J. Greenaway 2022-10-19 17:06:04 -07:00
parent df5137a14b
commit 6bafb7264c
No known key found for this signature in database
GPG key ID: 10B62F8A7CAD7A41
2 changed files with 4 additions and 11 deletions

View file

@ -1149,6 +1149,7 @@ repos:
salt/ext/.*|
tests/.*
)$
additional_dependencies: ['importlib_metadata<5']
- repo: https://github.com/PyCQA/bandit
rev: "1.7.4"
hooks:
@ -1158,6 +1159,7 @@ repos:
args: [--silent, -lll, --skip, B701]
files: ^tests/.*
exclude: ^tests/minionswarm\.py
additional_dependencies: ['importlib_metadata<5']
# <---- Security ---------------------------------------------------------------------------------------------------
# ----- Pre-Commit ------------------------------------------------------------------------------------------------>

View file

@ -31,6 +31,7 @@ try:
# pylint: disable=unused-import,no-name-in-module
import napalm
import napalm.base as napalm_base
from napalm.base.exceptions import ConnectionClosedException
# pylint: enable=unused-import,no-name-in-module
HAS_NAPALM = True
@ -41,12 +42,6 @@ try:
except ImportError:
HAS_NAPALM = False
try:
from napalm.base.exceptions import ConnectionClosedException
HAS_CONN_CLOSED_EXC_CLASS = True
except ImportError:
HAS_CONN_CLOSED_EXC_CLASS = False
log = logging.getLogger(__file__)
@ -179,11 +174,7 @@ def call(napalm_device, method, *args, **kwargs):
method=method, driver=napalm_device.get("DRIVER_NAME")
)
)
elif (
retry
and HAS_CONN_CLOSED_EXC_CLASS
and isinstance(error, ConnectionClosedException)
):
elif retry and isinstance(error, ConnectionClosedException):
# Received disconection whilst executing the operation.
# Instructed to retry (default behaviour)
# thus trying to re-establish the connection