Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
Merge pull request #6 from northpowered/3-code-refactoring
  • Loading branch information
northpowered authored Sep 5, 2022
2 parents f251366 + 4a437aa commit 1e2cc74
Show file tree
Hide file tree
Showing 11 changed files with 381 additions and 321 deletions.
4 changes: 2 additions & 2 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ global:
unit: 'ms'

local:
src_addr: '0.0.0.0'
src_addr: '0.0.0.0'
timeout: 1
ttl: 64
size: 56
Expand All @@ -24,7 +24,7 @@ devices:
policies:
- name: mypolicy
max_rtt: 0.15

services:
- name: 'service01'
device: 'simplesla-local'
Expand Down
76 changes: 39 additions & 37 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
from cmath import log
from sla.sla import Sla
import sys
import argparse
import os
if __name__ == '__main__':

__version__ = '1.0.1'
__author__ = 'Romanov'

ap = argparse.ArgumentParser()

ap.add_argument('-c', '--config', required=True,
help='Path to configuration yaml file')

ap.add_argument('-v', '--verbose', required=False,
help='Logging level',choices=['DEBUG','INFO','WARNING','ERROR'])

ap.add_argument('-l', '--log-dest', required=False,
help='Logging path {stdout,FILE}')

ap.add_argument('--version', action='version', version=__version__)

args = vars(ap.parse_args())
log_level = args.get('verbose')
log_dest = args.get('log_dest')
if not log_level:
log_level = os.getenv('SSLA_LL', 'INFO')
if not log_dest:
log_dest = os.getenv('SSLA_LD', 'stdout')
try:
sla = Sla(
config_file=args.get('config'),
log_level=log_level,
log_dest=log_dest
)
sla.start()
except:
sys.exit()




if __name__ == "__main__":

__version__ = "1.0.2"
__author__ = "https://github.com/northpowered"

ap = argparse.ArgumentParser()

ap.add_argument(
"-c", "--config", required=True, help="Path to configuration yaml file"
)

ap.add_argument(
"-v",
"--verbose",
required=False,
help="Logging level",
choices=["DEBUG", "INFO", "WARNING", "ERROR"],
)

ap.add_argument(
"-l", "--log-dest", required=False, help="Logging path {stdout,FILE}"
)

ap.add_argument("--version", action="version", version=__version__)

args = vars(ap.parse_args())
log_level = args.get("verbose")
log_dest = args.get("log_dest")
if not log_level:
log_level = os.getenv("SSLA_LL", "INFO")
if not log_dest:
log_dest = os.getenv("SSLA_LD", "stdout")
try:
sla = Sla(
config_file=args.get("config"), log_level=log_level, log_dest=log_dest
)
sla.start()
except KeyboardInterrupt:
sys.exit()
15 changes: 13 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
asyncio==3.4.3
bcrypt==3.2.0
black==22.8.0
cffi==1.15.0
click==8.1.3
cryptography==36.0.1
Deprecated==1.2.13
flake8==5.0.4
future==0.18.2
googleapis-common-protos==1.54.0
grpcio==1.44.0
loguru==0.6.0
netmiko==3.4.0
mccabe==0.7.0
mypy==0.960
mypy-extensions==0.4.3
netmiko==4.1.2
ntc-templates==3.0.0
opentelemetry-api==1.9.1
opentelemetry-exporter-jaeger==1.9.1
Expand All @@ -17,10 +23,14 @@ opentelemetry-sdk==1.9.1
opentelemetry-semantic-conventions==0.28b1
packaging==21.3
paramiko==2.9.2
pathspec==0.10.1
ping3==3.0.2
platformdirs==2.5.2
prometheus-client==0.12.0
protobuf==3.19.4
pycodestyle==2.9.1
pycparser==2.21
pyflakes==2.5.0
PyNaCl==1.5.0
pyparsing==3.0.6
pyserial==3.5
Expand All @@ -32,6 +42,7 @@ six==1.16.0
tenacity==8.0.1
textfsm==1.1.2
thrift==0.15.0
typing-extensions==4.1.1
tomli==2.0.1
typing_extensions==4.1.1
wrapt==1.13.3
yml==0.0.1
Loading

0 comments on commit 1e2cc74

Please sign in to comment.