Skip to content

Commit

Permalink
Merge branch 'master' into zeroize_warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitin Kr authored Oct 28, 2020
2 parents 3b0bbc2 + 2ebf076 commit 4c1fd0c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ matrix:
python: 3.7
before_install:
- choco install python3 --version=3.7.4
- pip install ntc_templates==1.4.1
- pip install textfsm==0.4.1
env:
- PATH=/c/Python37:/c/Python37/Scripts:$PATH
- TRAVIS_PYTHON_VERSION=3.7
Expand Down
1 change: 1 addition & 0 deletions development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ nose # http://nose.readthedocs.org/en/latest/
pep8 # https://github.com/jcrocholl/pep8
pyflakes # https://launchpad.net/pyflakes
coveralls # https://coveralls.io/
ntc_templates # user needs to explicitly install this
5 changes: 3 additions & 2 deletions lib/jnpr/junos/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ class _Connection(object):
model_dict = {}
with open("/etc/product.conf") as f:
for line in f:
(key, val) = line.strip().split("=")
model_dict[key] = val
if "=" in line:
(key, val) = line.strip().split("=")
model_dict[key] = val

if "model" in model_dict and model_dict["model"] in [
"crpd",
Expand Down
20 changes: 16 additions & 4 deletions lib/jnpr/junos/factory/cmdtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
from jnpr.junos.factory.to_json import TableJSONEncoder

from jinja2 import Template
from ntc_templates import parse as ntc_parse

HAS_NTC_TEMPLATE = False
try:
from ntc_templates import parse as ntc_parse

HAS_NTC_TEMPLATE = True
except:
pass

import logging

Expand Down Expand Up @@ -153,9 +160,14 @@ def get(self, *vargs, **kvargs):
self.data = self.xml.text

if self.USE_TEXTFSM:
self.output = self._parse_textfsm(
platform=self.PLATFORM, command=self.GET_CMD, raw=self.data
)
if HAS_NTC_TEMPLATE:
self.output = self._parse_textfsm(
platform=self.PLATFORM, command=self.GET_CMD, raw=self.data
)
else:
raise ImportError(
"ntc_template is missing. Need to be installed explicitly."
)
else:
# state machine
sm = StateMachine(self)
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ pyserial
yamlordereddictloader
pyparsing
transitions
ntc_templates
10 changes: 1 addition & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
from setuptools import setup, find_packages
import sys
import versioneer

# parse requirements
req_lines = [line.strip() for line in open("requirements.txt").readlines()]
install_reqs = list(filter(None, req_lines))

# refer: https://github.com/Juniper/py-junos-eznc/issues/1015
# should be removed when textfsm releases >=1.1.1
if sys.platform == "win32":
if "ntc_templates" in install_reqs:
install_reqs.remove("ntc_templates")
install_reqs.append("ntc_templates==1.4.1")
install_reqs.append("textfsm==0.4.1")

setup(
name="junos-eznc",
namespace_packages=["jnpr"],
Expand Down Expand Up @@ -51,6 +42,7 @@
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Application Frameworks",
"Topic :: Software Development :: Libraries :: Python Modules",
Expand Down

0 comments on commit 4c1fd0c

Please sign in to comment.