Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated PR on Netmiko support for pip installed ntc-templates #1710

Closed
wants to merge 7 commits into from

Conversation

ktbyers
Copy link
Owner

@ktbyers ktbyers commented Apr 30, 2020

No description provided.

lykinsbd and others added 7 commits April 24, 2020 20:02
Per conversation in #1520, the following is now the hierarchy for
 finding the `ntc-templates/templates` directory:

1. Find directory in `NET_TEXTFSM` Environment Variable
2. Check for pip installed `ntc-templates` location in this environment
3. ~/ntc-templates/templates

If a valid directory is not found, that is even if one is referenced in
 the environment variable or found in the home directory, a ValueError
 will be raised.

Added two dependencies into the `setup.py` file:

1. `ntc-templates` so that going forward it will be automatically
 installed with Netmiko
2. `importlib_resources` if Python is less than 3.7
I was accidentally passing the entire path to `index` twice into CliTable.
@ktbyers
Copy link
Owner Author

ktbyers commented Apr 30, 2020

@lykinsbd Made some updates here mainly related to the importlib behavior. New solution should be quite a bit simpler.

I removed direct ntc-templates dependency. I probably won't be willing to do that until this issue outlined here is fixed:

networktocode/ntc-templates#672

Basically, I don't want that other terminal.py dependency in Netmiko (as that is unmaintained code) and caused me quite a bit of pain in the past.

Still some more review that I need to do.

@lykinsbd
Copy link
Contributor

lykinsbd commented May 2, 2020

@ktbyers I totally get waiting on making the direct dependency until terminal.py issue is sorted. 👍

As for the importlib.resources fix, that works for me. It is simpler and closer to what I originally did in in my first commit ( 13913fd ).

What I put afterwards, while more complicated, was focused on making importlib.resources importable by any module without needing the try...except block. And would hold true anywhere else in the program after that as it modified sys.modules.

I've used it in the past at the top level of a module/library initiation so that other developers could simply do import importlib.resources without caring what python version they are running.

It may not make sense to either use it at all in Netmiko, but more specifically may not make sense to do in utilities.py. Like I said, it makes sense to make it simpler, but wanted to give some background information on why I put the complicated version in there to start with.

@ktbyers
Copy link
Owner Author

ktbyers commented May 3, 2020

@lykinsbd Okay, that makes sense.

I would say for now we just leave it as the simpler solution and then we can see across time if there are other needs for it (in Netmko).

@ktbyers
Copy link
Owner Author

ktbyers commented Sep 23, 2020

Superceded by PR here: #1961

@ktbyers ktbyers closed this Sep 23, 2020
@ktbyers ktbyers deleted the lykinsbd-brett-ntc-templates2 branch June 3, 2021 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants