Skip to content

Commit

Permalink
Merge pull request #411 from chidanandpujar/mode_telnet_error_fix1
Browse files Browse the repository at this point in the history
Added fix to handle mode telnet
  • Loading branch information
dineshbaburam91 authored May 13, 2024
2 parents 09304fa + 0697db5 commit 5198af3
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 58 deletions.
32 changes: 22 additions & 10 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.7.12, 3.8.12, 3.9.12]
python-version: [3.8.12, 3.9.12, 3.10.12, 3.11.9]

steps:
- uses: actions/checkout@v2
Expand All @@ -34,22 +34,34 @@ jobs:

- name: Install dependencies
run: |
sudo python -m pip install --upgrade pip
sudo python -m pip install pylint
sudo python -m pip install -r requirements.txt
sudo python -m pip install -r development.txt
sudo python setup.py install
python -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install pylint
pip install -r requirements.txt
pip install -r development.txt
python setup.py sdist
ls dist/
cp dist/jsnapy-*.dev0.tar.gz ../
cd ../
tar -xzvf jsnapy-*.dev0.tar.gz
cd jsnapy-*.dev0
python setup.py install
- name: Analysing the code with pylint
run: |
sudo find . -type f -name "*.py" | xargs pylint | grep .
pip install pylint
sudo find ./lib/jnpr/jsnapy -type f -name "*.py" | xargs pylint | grep .
- name: Run black tool
run: |
sudo python -m pip install -U black;
sudo black --check --exclude="docs|build|tests|samples|venv" .
pip install -U black;
black --check --diff --exclude="docs|build|tests|samples|venv" .
- name: Run unit test
run: |
source venv/bin/activate
pip install -r development.txt
cd tests/unit
sudo nosetests -v --with-coverage --cover-package=jnpr.jsnapy --cover-inclusive -a unit
nose2 --with-coverage -vvvv
4 changes: 4 additions & 0 deletions development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ pyflakes # https://launchpad.net/pyflakes
coveralls # https://coveralls.io/
unittest2>=0.5.1 # https://pypi.python.org/pypi/unittest2
pytest
pyyaml
ntc_templates==1.4.1
textfsm==0.4.1
nose2
1 change: 0 additions & 1 deletion lib/jnpr/jsnapy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class DirStore:
# Function added by @gcasella
# To check if the user is currently running the installation inside of a virtual environment that was installed using the `python3 -m venv venv` command.
def venv_check():

if hasattr(sys, "real_prefix") or (
hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix
):
Expand Down
6 changes: 2 additions & 4 deletions lib/jnpr/jsnapy/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,8 @@ def generate_snap_file(self, device, prefix, name, reply_format):
return snapfile

def splitter(self, value):
f = (
lambda x: x.split("]")[1].count(",")
if "[" in x and "]" in x
else x.count(",")
f = lambda x: (
x.split("]")[1].count(",") if "[" in x and "]" in x else x.count(",")
)
value_list = [x[::-1].strip() for x in value[::-1].split(",", f(value))][::-1]
return value_list
Expand Down
6 changes: 5 additions & 1 deletion lib/jnpr/jsnapy/jsnapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ def connect_multiple_device(
if config_data is not None:
self.test_cases = self.extract_test_cases(config_data) # extract test cases

for (iter, key_value) in iteritems(host_dict):
for iter, key_value in iteritems(host_dict):
hostname = key_value.get("device")
username = self.args.login or key_value.get("username")
password = self.args.passwd or key_value.get("passwd")
Expand Down Expand Up @@ -961,6 +961,10 @@ def action_api_based(
res = self.api_based_handling_with_dev(
dev, config_data, pre_name, action, post_snap, local=local
)
elif dev is not None: # To handle mode = telnet
res = self.api_based_handling_with_dev(
dev, config_data, pre_name, action, post_snap, local=local
)
else:
res = self.api_based_handling(
config_data, pre_name, action, post_snap, local=local
Expand Down
Loading

0 comments on commit 5198af3

Please sign in to comment.