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

pkg_resources changes for PY3.13 #3492

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion netmiko/scp_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def progress_bar(

# Percentage done
percent_complete = sent / size
percent_str = f"{percent_complete*100:.2f}%"
percent_str = f"{percent_complete * 100:.2f}%"
hash_count = int(percent_complete * max_width)
progress = hash_count * ">"

Expand Down
26 changes: 17 additions & 9 deletions netmiko/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,23 @@ def get_template_dir(_skip_ntc_package: bool = False) -> str:
else:
# Try 'pip installed' ntc-templates
try:
with pkg_resources.path(
package="ntc_templates", resource="parse.py"
) as posix_path:
# Example: /opt/venv/netmiko/lib/python3.8/site-packages/ntc_templates/templates
template_dir = str(posix_path.parent.joinpath("templates"))
# This is for Netmiko automated testing
if _skip_ntc_package:
raise ModuleNotFoundError()

# New API for Python 3.13+
if sys.version_info >= (3, 13):
with pkg_resources.path("ntc_templates", "parse.py") as posix_path:
# Example: /venv/netmiko/lib/python3.13/site-packages/ntc_templates/templates
template_dir = str(posix_path.parent.joinpath("templates"))
# This is for Netmiko automated testing
if _skip_ntc_package:
raise ModuleNotFoundError()
else:
with pkg_resources.path(
package="ntc_templates", resource="parse.py"
) as posix_path:
# Example: /opt/venv/netmiko/lib/python3.9/site-packages/ntc_templates/templates
template_dir = str(posix_path.parent.joinpath("templates"))
# This is for Netmiko automated testing
if _skip_ntc_package:
raise ModuleNotFoundError()
except ModuleNotFoundError:
# Finally check in ~/ntc-templates/ntc_templates/templates
home_dir = os.path.expanduser("~")
Expand Down