Skip to content

Commit

Permalink
Small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
romanov committed Sep 8, 2022
1 parent fed5dbc commit 9b109bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/documetation-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Documentation deployment
on:
push:
branches:
- master
- master
- main
jobs:
deploy:
Expand All @@ -13,5 +13,5 @@ jobs:
- uses: actions/setup-python@v3
with:
python-version: 3.x
- run: pip install mkdocs-material
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
24 changes: 10 additions & 14 deletions sla/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,14 @@ def __get_rtt_remote(self, hnd: BaseConnection, target: str, fsm: textfsm.TextFS
output = fsm.ParseText(result)
try:
_ = float(output[0][0])
except IndexError as ex:
except IndexError:
_ = None
except Exception as ex:
except Exception:
_ = False
finally:
return _
return _

def __batch_remote_check(self, hnd: BaseConnection, targets: list, fsm: textfsm.TextFSM) -> dict:
iter: int = 0
result_iterator: int = 0
for target in targets:
sleep(target.delay)
_ = None
Expand All @@ -107,13 +106,13 @@ def __batch_remote_check(self, hnd: BaseConnection, targets: list, fsm: textfsm.
output = fsm.ParseText(result)
LG.debug(f"Parsed data [{output}] from {self.name} device")
try:
rtt = float(output[iter][0])
except IndexError as ex:
rtt = float(output[result_iterator][0])
except IndexError:
rtt = None
except Exception as ex:
except Exception:
rtt = False
target.__setattr__('rtt', rtt)
iter = iter + 1
result_iterator = result_iterator + 1
return targets

def __get_rtt_local(self, target: str):
Expand All @@ -131,10 +130,7 @@ def __get_rtt_local(self, target: str):
LG.error(f"Wrong Ipv4 syntax: {target}")
except OSError as error:
LG.error(f"Source interface/address {error} is not exist")
else:
pass
finally:
return _
return _

def get_rtt(self, target: str | list) -> str | dict:
with device_tracer.start_as_current_span(__name__) as span:
Expand All @@ -156,7 +152,7 @@ def get_rtt(self, target: str | list) -> str | dict:
LG.error(f"Template file {self.template} not found")
except NetmikoTimeoutException:
LG.warning(f"Unreachable device. Connection with {self.name} failed")
except NetmikoAuthenticationException as error:
except NetmikoAuthenticationException:
LG.warning(f"Authentication with {self.name} failed. Check credentials")
else:
LG.error(f"Unknown device type {self.type}")
Expand Down

0 comments on commit 9b109bd

Please sign in to comment.