From ec31938a12489fed78714ba1d248affdab111263 Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Thu, 30 Dec 2021 22:04:25 -0500 Subject: [PATCH 1/3] simplify paramiko import * remove custom "please install paramiko" message logic * import directly, not through fabric.network in some cases --- fabric/network.py | 16 ++-------------- fabric/state.py | 4 +++- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/fabric/network.py b/fabric/network.py index 28800c05..56e9b467 100644 --- a/fabric/network.py +++ b/fabric/network.py @@ -11,24 +11,12 @@ import socket import sys +import paramiko as ssh + from fabric.auth import get_password, set_password from fabric.utils import handle_prompt_abort, warn from fabric.exceptions import NetworkError -try: - import warnings - warnings.simplefilter('ignore', DeprecationWarning) - import paramiko as ssh -except ImportError: - import traceback - traceback.print_exc() - msg = """ -There was a problem importing our SSH library (see traceback above). -Please make sure all dependencies are installed and importable. -""".rstrip() - sys.stderr.write(msg + '\n') - sys.exit(1) - ipv6_regex = re.compile( r'^\[?(?P[0-9A-Fa-f:]+(?:%[a-z]+\d+)?)\]?(:(?P\d+))?$') diff --git a/fabric/state.py b/fabric/state.py index f3fa1a0a..c09bb903 100644 --- a/fabric/state.py +++ b/fabric/state.py @@ -6,7 +6,9 @@ import sys from optparse import make_option -from fabric.network import HostConnectionCache, ssh +import paramiko as ssh + +from fabric.network import HostConnectionCache from fabric.version import get_version from fabric.utils import _AliasDict, _AttributeDict From 0aeb00f35c6eb8aed58866ec4ee1c48bf1a613f1 Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Thu, 30 Dec 2021 22:06:36 -0500 Subject: [PATCH 2/3] tasks: remove python-2.5 inspect.getargspec() support --- fabric/tasks.py | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/fabric/tasks.py b/fabric/tasks.py index 1b36f8ec..47a2b49f 100644 --- a/fabric/tasks.py +++ b/fabric/tasks.py @@ -11,26 +11,6 @@ from fabric.task_utils import crawl, merge, parse_kwargs from fabric.exceptions import NetworkError -if sys.version_info[:2] == (2, 5): - # Python 2.5 inspect.getargspec returns a tuple - # instead of ArgSpec namedtuple. - class ArgSpec(object): - def __init__(self, args, varargs, keywords, defaults): - self.args = args - self.varargs = varargs - self.keywords = keywords - self.defaults = defaults - self._tuple = (args, varargs, keywords, defaults) - - def __getitem__(self, idx): - return self._tuple[idx] - - def patched_get_argspec(func): - return ArgSpec(*inspect._getargspec(func)) - - inspect._getargspec = inspect.getargspec - inspect.getargspec = patched_get_argspec - def get_task_details(task): details = [ @@ -39,7 +19,7 @@ def get_task_details(task): else 'No docstring provided'] argspec = inspect.getargspec(task) - default_args = [] if not argspec.defaults else argspec.defaults + default_args = argspec.defaults or () num_default_args = len(default_args) args_without_defaults = argspec.args[:len(argspec.args) - num_default_args] args_with_defaults = argspec.args[-1 * num_default_args:] @@ -78,8 +58,7 @@ class Task(object): is_default = False # TODO: make it so that this wraps other decorators as expected - def __init__(self, alias=None, aliases=None, default=False, name=None, - *args, **kwargs): + def __init__(self, alias=None, aliases=None, default=False, name=None, *args, **kwargs): if alias is not None: self.aliases = [alias, ] if aliases is not None: From 3bc6e216a1b6080e1c0647205e8606908939630c Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Thu, 30 Dec 2021 22:20:21 -0500 Subject: [PATCH 3/3] CI: update test matrix paramiko-ng versions --- .github/workflows/linux.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 8646e11a..36622a87 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -21,9 +21,9 @@ jobs: - 3.9-bullseye - 3.10-bullseye paramiko_ver: - - 2.5.0 - - 2.7.8 - - 2.8.4 + - 2.6.4 + - 2.7.10 + - 2.8.8 container: "python:${{matrix.imgtag}}" steps: - uses: actions/checkout@v2