diff --git a/netmiko/scp_functions.py b/netmiko/scp_functions.py index 20c5737ff..876c3f202 100644 --- a/netmiko/scp_functions.py +++ b/netmiko/scp_functions.py @@ -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 * ">" diff --git a/netmiko/utilities.py b/netmiko/utilities.py index 2bc60cfe8..d425db761 100644 --- a/netmiko/utilities.py +++ b/netmiko/utilities.py @@ -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("~")