lint check by pylama
This commit is contained in:
1 parent
e9d5398eaa
commit
e3a650a0ed
2 files changed
+14
-26
No files matched your search
+9
-11
@@ -248,7 +248,7 @@ class S350Driver(NetworkDriver):
|
|||||||
# serial_number and model
|
# serial_number and model
|
||||||
inventory = self._get_facts_parse_inventory(show_inv)['1']
|
inventory = self._get_facts_parse_inventory(show_inv)['1']
|
||||||
serial_number = inventory['sn']
|
serial_number = inventory['sn']
|
||||||
model = inventory['pid']
|
model = inventory['pid']
|
||||||
|
|
||||||
# fqdn
|
# fqdn
|
||||||
domainname = napalm.base.helpers.textfsm_extractor(self, 'hosts',
|
domainname = napalm.base.helpers.textfsm_extractor(self, 'hosts',
|
||||||
@@ -361,7 +361,7 @@ class S350Driver(NetworkDriver):
|
|||||||
for line in show_ver.splitlines():
|
for line in show_ver.splitlines():
|
||||||
line = re.sub(r' *', ' ', line, re.M)
|
line = re.sub(r' *', ' ', line, re.M)
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
line_comps= line.split(' ')
|
line_comps = line.split(' ')
|
||||||
if line_comps[0] == '1':
|
if line_comps[0] == '1':
|
||||||
os_version = line_comps[1]
|
os_version = line_comps[1]
|
||||||
break
|
break
|
||||||
@@ -395,7 +395,6 @@ class S350Driver(NetworkDriver):
|
|||||||
# from the first port and use it everywhere.
|
# from the first port and use it everywhere.
|
||||||
if mac == '0':
|
if mac == '0':
|
||||||
show_system_output = self._send_command('show lldp local ' + interface)
|
show_system_output = self._send_command('show lldp local ' + interface)
|
||||||
|
|
||||||
mac = show_system_output.splitlines()[0].split(':', maxsplit=1)[1].strip()
|
mac = show_system_output.splitlines()[0].split(':', maxsplit=1)[1].strip()
|
||||||
|
|
||||||
if speed == '--':
|
if speed == '--':
|
||||||
@@ -451,7 +450,7 @@ class S350Driver(NetworkDriver):
|
|||||||
|
|
||||||
# only valid interfaces
|
# only valid interfaces
|
||||||
# in diferent firmwares there is 'Status' field allwais on last place
|
# in diferent firmwares there is 'Status' field allwais on last place
|
||||||
if line_elems[len(line_elems) -1] != 'Valid':
|
if line_elems[len(line_elems) - 1] != 'Valid':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
cidr = line_elems[0]
|
cidr = line_elems[0]
|
||||||
@@ -511,9 +510,9 @@ class S350Driver(NetworkDriver):
|
|||||||
line_elems = self._get_lldp_neighbors_line_to_fields(line, fields_end)
|
line_elems = self._get_lldp_neighbors_line_to_fields(line, fields_end)
|
||||||
|
|
||||||
# info owerflow to the other line
|
# info owerflow to the other line
|
||||||
if line_elems[0] == '' or line_elems[4] == '' or line_elems[5] == '' :
|
if line_elems[0] == '' or line_elems[4] == '' or line_elems[5] == '' :
|
||||||
# complete owerflown fields
|
# complete owerflown fields
|
||||||
local_port = local_port + line_elems[0]
|
local_port = local_port + line_elems[0]
|
||||||
remote_port = remote_port + line_elems[2]
|
remote_port = remote_port + line_elems[2]
|
||||||
remote_name = remote_name + line_elems[3]
|
remote_name = remote_name + line_elems[3]
|
||||||
# then reuse old values na rewrite previous entry
|
# then reuse old values na rewrite previous entry
|
||||||
@@ -533,9 +532,9 @@ class S350Driver(NetworkDriver):
|
|||||||
|
|
||||||
def _get_lldp_neighbors_line_to_fields(self, line, fields_end):
|
def _get_lldp_neighbors_line_to_fields(self, line, fields_end):
|
||||||
""" dynamic fields lenghts """
|
""" dynamic fields lenghts """
|
||||||
line_elems={}
|
line_elems = {}
|
||||||
index=0
|
index = 0
|
||||||
f_start=0
|
f_start = 0
|
||||||
for f_end in fields_end:
|
for f_end in fields_end:
|
||||||
line_elems[index] = line[f_start:f_end].strip()
|
line_elems[index] = line[f_start:f_end].strip()
|
||||||
index += 1
|
index += 1
|
||||||
@@ -545,8 +544,7 @@ class S350Driver(NetworkDriver):
|
|||||||
def _get_lldp_neighbors_fields_end(self, dashline):
|
def _get_lldp_neighbors_fields_end(self, dashline):
|
||||||
""" fields length are diferent device to device, detect them on horizontal lin """
|
""" fields length are diferent device to device, detect them on horizontal lin """
|
||||||
|
|
||||||
fields_end=[m.start() for m in re.finditer(' ', dashline)]
|
fields_end = [m.start() for m in re.finditer(' ', dashline)]
|
||||||
#fields_position.insert(0,0)
|
|
||||||
fields_end.append(len(dashline))
|
fields_end.append(len(dashline))
|
||||||
|
|
||||||
return fields_end
|
return fields_end
|
||||||
|
|||||||
@@ -1,16 +1,8 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = py3{6,7,8},black,pylama
|
#envlist = py3{6,7,8},black,pylama,sphinx
|
||||||
|
envlist = py3{6,7,8},pylama
|
||||||
skip_missing_interpreters = true
|
skip_missing_interpreters = true
|
||||||
|
|
||||||
[travis]
|
|
||||||
python =
|
|
||||||
3.6: py36,black,pylama
|
|
||||||
|
|
||||||
[travis:env]
|
|
||||||
TRAVIS_BUILD_STAGE_NAME =
|
|
||||||
Lint: black,pylama
|
|
||||||
Test: py3{6,7,8}
|
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps =
|
deps =
|
||||||
-rrequirements.txt
|
-rrequirements.txt
|
||||||
@@ -21,17 +13,16 @@ commands =
|
|||||||
py.test --cov=napalm_s350 --cov-report term-missing -vs {posargs}
|
py.test --cov=napalm_s350 --cov-report term-missing -vs {posargs}
|
||||||
|
|
||||||
[testenv:black]
|
[testenv:black]
|
||||||
deps = black==18.9b0
|
deps =
|
||||||
|
-rrequirements-dev.txt
|
||||||
|
|
||||||
basepython = python3.6
|
|
||||||
commands =
|
commands =
|
||||||
black --check .
|
black --check --target-version py36 --line-length 100 --color --diff .
|
||||||
|
|
||||||
[testenv:pylama]
|
[testenv:pylama]
|
||||||
deps =
|
deps =
|
||||||
-rrequirements-dev.txt
|
-rrequirements-dev.txt
|
||||||
|
|
||||||
basepython = python3.6
|
|
||||||
commands =
|
commands =
|
||||||
pylama .
|
pylama .
|
||||||
|
|
||||||
@@ -39,7 +30,6 @@ commands =
|
|||||||
deps =
|
deps =
|
||||||
-rdocs/requirements.txt
|
-rdocs/requirements.txt
|
||||||
|
|
||||||
basepython = python3.6
|
|
||||||
|
|
||||||
commands =
|
commands =
|
||||||
make doctest
|
make doctest
|
||||||
|
|||||||
Reference in new issue
Block a user