Skip to content

Commit 980edac

Browse files
committed
block share connection logic, it is not ready for release
1 parent 83488d9 commit 980edac

File tree

4 files changed

+29
-22
lines changed

4 files changed

+29
-22
lines changed

docs/source/usage_multi.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ Instantiating class provides a simple interface similar to factory
3030
.. code-block:: python
3131
3232
>>> from ssh_utilities import MultiConnection
33-
>>> MultiConnection(<server_names_list>, local=False, thread_safe=True,
34-
>>> share_connection=False)
33+
>>> MultiConnection(<server_names_list>, local=False, thread_safe=True)
3534
>>> <ssh_utilities.ssh_utilities.MultiConnection at 0x7efedff4fb38>
3635
3736
``MultiConnection`` class can also be used as a contextmanager.
@@ -40,13 +39,13 @@ Instantiating class provides a simple interface similar to factory
4039
4140
>>> from ssh_utilities import MultiConnection
4241
>>> with MultiConnection(<server_names_list>, local=False,
43-
thread_safe=True, share_connection=False) as mc:
42+
thread_safe=True) as mc:
4443
>>> mc.<some_attribute>
4544
>>> ...
4645
4746
.. note::
4847

49-
``local``, ``thread_safe`` and ``share_connection`` arguments can also be
48+
``local`` and ``thread_safe`` arguments can also be
5049
lists with length corresponding to ``server_names`` each element in these
5150
lists will be used with corresponding connection otherwise the arguments
5251
will be same for all connections.
@@ -78,6 +77,10 @@ without parameters and than add individual connections one by one.
7877
>>> mc2 = mc + mc1 # you can also join MultiConnection instances
7978
>>> mc2.update(mc1) # or use dict interface
8079
80+
.. warning::
81+
82+
You cannot add more connections under same key!
83+
8184

8285
Fully aupported dictionary interface also allows you to easilly access and
8386
manipulate individual connections in container.

ssh_utilities/multi_connection/_dict_interface.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
"""module providing dictionary interface for multi_connection."""
1+
"""Module providing dictionary interface for multi_connection."""
22

33
import logging
44
from copy import copy
55
from typing import (TYPE_CHECKING, Dict, ItemsView, KeysView, Optional, Tuple,
66
Union, ValuesView, TypeVar)
7+
from collections.abc import MutableMapping
78

89
if TYPE_CHECKING:
910
from ..local import LocalConnection
@@ -16,7 +17,7 @@
1617
log = logging.getLogger(__name__)
1718

1819

19-
class DictInterface:
20+
class DictInterface(MutableMapping):
2021
"""Class providing dictionary interface methods to MultiConnection.
2122
2223
See also

ssh_utilities/multi_connection/_persistence.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def __setstate__(self, state: dict):
6060
)
6161

6262
self.__init__(ssh_servers, local, quiet=True, # type: ignore
63-
thread_safe=thread_safe,
64-
share_connection=share_connection)
63+
thread_safe=thread_safe)
64+
# share_connection=share_connection)
6565

6666
def to_dict(self) -> Dict[int, Dict[str, Optional[Union[str, bool,
6767
int, None]]]]:
@@ -139,8 +139,8 @@ def from_dict(cls, json: dict, quiet: bool = False
139139
)
140140

141141
return cls(ssh_servers, local, quiet=quiet, # type: ignore
142-
thread_safe=thread_safe,
143-
share_connection=share_connection)
142+
thread_safe=thread_safe)
143+
# share_connection=share_connection)
144144

145145
@classmethod
146146
def from_str(cls, string: str, quiet: bool = False

ssh_utilities/multi_connection/multi_connection.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,18 @@ class MultiConnection(DictInterface, Pesistence, ConnectionABC):
4040
Parameters
4141
----------
4242
ssh_servers : Union[List[str], str]
43-
[description]
43+
list od ssh srevers to connect to
4444
local : Union[List[bool], bool], optional
45-
[description], by default False
45+
bool or list of bools specifying if the respective connection(s),
46+
should be local or remote by default False
4647
quiet : bool, optional
47-
[description], by default False
48+
bool or a list of bools specifing if login messages should be printed,
49+
on individula connections initialization by default False
4850
thread_safe : Union[List[bool], bool], optional
49-
[description], by default False
51+
bool or a list of bools specifying if respective connection(s) should,
52+
be made thead safe or not by default False
5053
share_connection : Union[List[int], int], optional
51-
[description], by default 1
54+
Not implemented, by default 1
5255
"""
5356

5457
_builtins: "_BUILTINS_MULTI"
@@ -61,9 +64,9 @@ class MultiConnection(DictInterface, Pesistence, ConnectionABC):
6164
def __init__(self, ssh_servers: Union[List[str], str],
6265
local: Union[List[bool], bool] = False, quiet: bool = False,
6366
thread_safe: Union[List[bool], bool] = False) -> None:
64-
65-
# TODO implement share connection
6667
# share_connection: Union[List[int], int] = 1) -> None:
68+
69+
# TODO finish implementation
6770
share_connection: Union[List[int], int] = 1
6871

6972
# TODO somehow adjust number of workers if connection are deleted or
@@ -98,39 +101,39 @@ def __init__(self, ssh_servers: Union[List[str], str],
98101
def builtins(self) -> "_BUILTINS_MULTI":
99102
"""Inner class providing access to substitutions for python builtins.
100103
101-
:type: .remote.Builtins
104+
:type: .abc.Builtins
102105
"""
103106
return self._builtins
104107

105108
@property
106109
def os(self) -> "_OS_MULTI":
107110
"""Inner class providing access to substitutions for python os module.
108111
109-
:type: .remote.Os
112+
:type: .abc.Os
110113
"""
111114
return self._os
112115

113116
@property
114117
def pathlib(self) -> "_PATHLIB_MULTI":
115118
"""Inner class providing access to substitutions for pathlib module.
116119
117-
:type: .remote.Pathlib
120+
:type: .abc.Pathlib
118121
"""
119122
return self._pathlib
120123

121124
@property
122125
def shutil(self) -> "_SHUTIL_MULTI":
123126
"""Inner class providing access to substitutions for shutil module.
124127
125-
:type: .remote.Shutil
128+
:type: .abc.Shutil
126129
"""
127130
return self._shutil
128131

129132
@property
130133
def subprocess(self) -> "_SUBPROCESS_MULTI":
131134
"""Inner class providing access to substitutions for subprocess module.
132135
133-
:type: .remote.Subprocess
136+
:type: .abc.Subprocess
134137
"""
135138
return self._subprocess
136139

0 commit comments

Comments
 (0)