Skip to content

Commit

Permalink
version bump, doc gen
Browse files Browse the repository at this point in the history
  • Loading branch information
carlmontanari committed Jul 4, 2020
1 parent f7fefeb commit 389c73f
Show file tree
Hide file tree
Showing 16 changed files with 550 additions and 1,003 deletions.
64 changes: 39 additions & 25 deletions docs/scrapli/channel/async_channel.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ <h1 class="title">Module <code>scrapli.channel.async_channel</code></h1>
current_prompt = channel_match.group(0)
return current_prompt.decode().strip()

async def send_input(self, channel_input: str, strip_prompt: bool = True) -&gt; Tuple[str, str]:
async def send_input(
self, channel_input: str, strip_prompt: bool = True
) -&gt; Tuple[bytes, bytes]:
&#34;&#34;&#34;
Primary entry point to send data to devices in async shell mode; accept input, return result

Expand All @@ -194,7 +196,7 @@ <h1 class="title">Module <code>scrapli.channel.async_channel</code></h1>
raw_result, processed_result = await self._async_send_input(
channel_input=channel_input, strip_prompt=strip_prompt
)
return raw_result.decode(), processed_result.decode()
return raw_result, processed_result

@operation_timeout(&#34;timeout_ops&#34;, &#34;Timed out sending input to device.&#34;)
async def _async_send_input(
Expand Down Expand Up @@ -236,7 +238,7 @@ <h1 class="title">Module <code>scrapli.channel.async_channel</code></h1>
@operation_timeout(&#34;timeout_ops&#34;, &#34;Timed out sending interactive input to device.&#34;)
async def send_inputs_interact(
self, interact_events: List[Tuple[str, str, Optional[bool]]]
) -&gt; Tuple[str, str]:
) -&gt; Tuple[bytes, bytes]:
&#34;&#34;&#34;
Async interact with a device with changing prompts per input.

Expand Down Expand Up @@ -505,7 +507,9 @@ <h2 id="raises">Raises</h2>
current_prompt = channel_match.group(0)
return current_prompt.decode().strip()

async def send_input(self, channel_input: str, strip_prompt: bool = True) -&gt; Tuple[str, str]:
async def send_input(
self, channel_input: str, strip_prompt: bool = True
) -&gt; Tuple[bytes, bytes]:
&#34;&#34;&#34;
Primary entry point to send data to devices in async shell mode; accept input, return result

Expand All @@ -525,7 +529,7 @@ <h2 id="raises">Raises</h2>
raw_result, processed_result = await self._async_send_input(
channel_input=channel_input, strip_prompt=strip_prompt
)
return raw_result.decode(), processed_result.decode()
return raw_result, processed_result

@operation_timeout(&#34;timeout_ops&#34;, &#34;Timed out sending input to device.&#34;)
async def _async_send_input(
Expand Down Expand Up @@ -567,7 +571,7 @@ <h2 id="raises">Raises</h2>
@operation_timeout(&#34;timeout_ops&#34;, &#34;Timed out sending interactive input to device.&#34;)
async def send_inputs_interact(
self, interact_events: List[Tuple[str, str, Optional[bool]]]
) -&gt; Tuple[str, str]:
) -&gt; Tuple[bytes, bytes]:
&#34;&#34;&#34;
Async interact with a device with changing prompts per input.

Expand Down Expand Up @@ -665,7 +669,7 @@ <h3>Ancestors</h3>
<h3>Methods</h3>
<dl>
<dt id="scrapli.channel.async_channel.AsyncChannel.get_prompt"><code class="name flex">
<span>def <span class="ident">get_prompt</span></span>(<span>channel_or_transport: Union[ForwardRef('Channel'), ForwardRef('Transport')], *args: Union[str, int], **kwargs: Dict[str, Union[str, int]]) -> Any</span>
<span>def <span class="ident">get_prompt</span></span>(<span>channel_or_transport: Union[ForwardRef('Channel'), ForwardRef('Transport')], *args: Any, **kwargs: Dict[str, Union[str, int]]) -> Any</span>
</code></dt>
<dd>
<div class="desc"></div>
Expand All @@ -675,7 +679,7 @@ <h3>Methods</h3>
</summary>
<pre><code class="python">def timeout_wrapper(
channel_or_transport: Union[&#34;Channel&#34;, &#34;Transport&#34;],
*args: Union[str, int],
*args: Any,
**kwargs: Dict[str, Union[str, int]],
) -&gt; Any:
# import here to avoid circular dependency
Expand All @@ -702,22 +706,26 @@ <h3>Methods</h3>
session_lock = channel_or_transport.session_lock
close = channel_or_transport.close

pool = ThreadPoolExecutor(max_workers=1)
future = pool.submit(wrapped_func, channel_or_transport, *args, **kwargs)
wait([future], timeout=timeout_duration)
if not future.done():
pool = multiprocessing.pool.ThreadPool(processes=1)
func_args = [channel_or_transport, *args]
future = pool.apply_async(wrapped_func, func_args, kwargs)
try:
result = future.get(timeout=timeout_duration)
pool.terminate()
return result
except multiprocessing.context.TimeoutError:
pool.terminate()
channel_or_transport.logger.info(message)
if timeout_exit:
channel_or_transport.logger.info(&#34;timeout_exit is True, closing transport&#34;)
if session_lock.locked():
session_lock.release()
close()
raise TimeoutError(message)
return future.result()</code></pre>
raise ScrapliTimeout(message)</code></pre>
</details>
</dd>
<dt id="scrapli.channel.async_channel.AsyncChannel.send_input"><code class="name flex">
<span>async def <span class="ident">send_input</span></span>(<span>self, channel_input: str, strip_prompt: bool = True) -> Tuple[str, str]</span>
<span>async def <span class="ident">send_input</span></span>(<span>self, channel_input: str, strip_prompt: bool = True) -> Tuple[bytes, bytes]</span>
</code></dt>
<dd>
<div class="desc"><p>Primary entry point to send data to devices in async shell mode; accept input, return result</p>
Expand All @@ -744,7 +752,9 @@ <h2 id="raises">Raises</h2>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">async def send_input(self, channel_input: str, strip_prompt: bool = True) -&gt; Tuple[str, str]:
<pre><code class="python">async def send_input(
self, channel_input: str, strip_prompt: bool = True
) -&gt; Tuple[bytes, bytes]:
&#34;&#34;&#34;
Primary entry point to send data to devices in async shell mode; accept input, return result

Expand All @@ -764,11 +774,11 @@ <h2 id="raises">Raises</h2>
raw_result, processed_result = await self._async_send_input(
channel_input=channel_input, strip_prompt=strip_prompt
)
return raw_result.decode(), processed_result.decode()</code></pre>
return raw_result, processed_result</code></pre>
</details>
</dd>
<dt id="scrapli.channel.async_channel.AsyncChannel.send_inputs_interact"><code class="name flex">
<span>def <span class="ident">send_inputs_interact</span></span>(<span>channel_or_transport: Union[ForwardRef('Channel'), ForwardRef('Transport')], *args: Union[str, int], **kwargs: Dict[str, Union[str, int]]) -> Any</span>
<span>def <span class="ident">send_inputs_interact</span></span>(<span>channel_or_transport: Union[ForwardRef('Channel'), ForwardRef('Transport')], *args: Any, **kwargs: Dict[str, Union[str, int]]) -> Any</span>
</code></dt>
<dd>
<div class="desc"></div>
Expand All @@ -778,7 +788,7 @@ <h2 id="raises">Raises</h2>
</summary>
<pre><code class="python">def timeout_wrapper(
channel_or_transport: Union[&#34;Channel&#34;, &#34;Transport&#34;],
*args: Union[str, int],
*args: Any,
**kwargs: Dict[str, Union[str, int]],
) -&gt; Any:
# import here to avoid circular dependency
Expand All @@ -805,18 +815,22 @@ <h2 id="raises">Raises</h2>
session_lock = channel_or_transport.session_lock
close = channel_or_transport.close

pool = ThreadPoolExecutor(max_workers=1)
future = pool.submit(wrapped_func, channel_or_transport, *args, **kwargs)
wait([future], timeout=timeout_duration)
if not future.done():
pool = multiprocessing.pool.ThreadPool(processes=1)
func_args = [channel_or_transport, *args]
future = pool.apply_async(wrapped_func, func_args, kwargs)
try:
result = future.get(timeout=timeout_duration)
pool.terminate()
return result
except multiprocessing.context.TimeoutError:
pool.terminate()
channel_or_transport.logger.info(message)
if timeout_exit:
channel_or_transport.logger.info(&#34;timeout_exit is True, closing transport&#34;)
if session_lock.locked():
session_lock.release()
close()
raise TimeoutError(message)
return future.result()</code></pre>
raise ScrapliTimeout(message)</code></pre>
</details>
</dd>
</dl>
Expand Down
12 changes: 6 additions & 6 deletions docs/scrapli/channel/base_channel.html
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ <h1 class="title">Module <code>scrapli.channel.base_channel</code></h1>
if not isinstance(interact_events, list):
raise TypeError(f&#34;`interact_events` expects a List, got {type(interact_events)}&#34;)

def _post_send_inputs_interact(self, output: bytes) -&gt; Tuple[str, str]:
def _post_send_inputs_interact(self, output: bytes) -&gt; Tuple[bytes, bytes]:
&#34;&#34;&#34;
Handle pre &#34;send_inputs_interact&#34; tasks for consistency between sync/async versions

Expand All @@ -247,8 +247,8 @@ <h1 class="title">Module <code>scrapli.channel.base_channel</code></h1>

&#34;&#34;&#34;
processed_output = self._restructure_output(output=output, strip_prompt=False)
raw_result = output.decode()
processed_result = processed_output.decode()
raw_result = output
processed_result = processed_output
return raw_result, processed_result</code></pre>
</details>
</section>
Expand Down Expand Up @@ -502,7 +502,7 @@ <h2 id="raises">Raises</h2>
if not isinstance(interact_events, list):
raise TypeError(f&#34;`interact_events` expects a List, got {type(interact_events)}&#34;)

def _post_send_inputs_interact(self, output: bytes) -&gt; Tuple[str, str]:
def _post_send_inputs_interact(self, output: bytes) -&gt; Tuple[bytes, bytes]:
&#34;&#34;&#34;
Handle pre &#34;send_inputs_interact&#34; tasks for consistency between sync/async versions

Expand All @@ -517,8 +517,8 @@ <h2 id="raises">Raises</h2>

&#34;&#34;&#34;
processed_output = self._restructure_output(output=output, strip_prompt=False)
raw_result = output.decode()
processed_result = processed_output.decode()
raw_result = output
processed_result = processed_output
return raw_result, processed_result</code></pre>
</details>
<h3>Ancestors</h3>
Expand Down
58 changes: 33 additions & 25 deletions docs/scrapli/channel/channel.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ <h1 class="title">Module <code>scrapli.channel.channel</code></h1>
current_prompt = channel_match.group(0)
return current_prompt.decode().strip()

def send_input(self, channel_input: str, strip_prompt: bool = True,) -&gt; Tuple[str, str]:
def send_input(self, channel_input: str, strip_prompt: bool = True) -&gt; Tuple[bytes, bytes]:
&#34;&#34;&#34;
Primary entry point to send data to devices in shell mode; accept input and returns result

Expand All @@ -192,7 +192,7 @@ <h1 class="title">Module <code>scrapli.channel.channel</code></h1>
raw_result, processed_result = self._send_input(
channel_input=channel_input, strip_prompt=strip_prompt
)
return raw_result.decode(), processed_result.decode()
return raw_result, processed_result

@operation_timeout(&#34;timeout_ops&#34;, &#34;Timed out sending input to device.&#34;)
def _send_input(self, channel_input: str, strip_prompt: bool) -&gt; Tuple[bytes, bytes]:
Expand Down Expand Up @@ -229,7 +229,7 @@ <h1 class="title">Module <code>scrapli.channel.channel</code></h1>
@operation_timeout(&#34;timeout_ops&#34;, &#34;Timed out sending interactive input to device.&#34;)
def send_inputs_interact(
self, interact_events: List[Tuple[str, str, Optional[bool]]]
) -&gt; Tuple[str, str]:
) -&gt; Tuple[bytes, bytes]:
&#34;&#34;&#34;
Interact with a device with changing prompts per input.

Expand Down Expand Up @@ -496,7 +496,7 @@ <h2 id="raises">Raises</h2>
current_prompt = channel_match.group(0)
return current_prompt.decode().strip()

def send_input(self, channel_input: str, strip_prompt: bool = True,) -&gt; Tuple[str, str]:
def send_input(self, channel_input: str, strip_prompt: bool = True) -&gt; Tuple[bytes, bytes]:
&#34;&#34;&#34;
Primary entry point to send data to devices in shell mode; accept input and returns result

Expand All @@ -516,7 +516,7 @@ <h2 id="raises">Raises</h2>
raw_result, processed_result = self._send_input(
channel_input=channel_input, strip_prompt=strip_prompt
)
return raw_result.decode(), processed_result.decode()
return raw_result, processed_result

@operation_timeout(&#34;timeout_ops&#34;, &#34;Timed out sending input to device.&#34;)
def _send_input(self, channel_input: str, strip_prompt: bool) -&gt; Tuple[bytes, bytes]:
Expand Down Expand Up @@ -553,7 +553,7 @@ <h2 id="raises">Raises</h2>
@operation_timeout(&#34;timeout_ops&#34;, &#34;Timed out sending interactive input to device.&#34;)
def send_inputs_interact(
self, interact_events: List[Tuple[str, str, Optional[bool]]]
) -&gt; Tuple[str, str]:
) -&gt; Tuple[bytes, bytes]:
&#34;&#34;&#34;
Interact with a device with changing prompts per input.

Expand Down Expand Up @@ -651,7 +651,7 @@ <h3>Ancestors</h3>
<h3>Methods</h3>
<dl>
<dt id="scrapli.channel.channel.Channel.get_prompt"><code class="name flex">
<span>def <span class="ident">get_prompt</span></span>(<span>channel_or_transport: Union[ForwardRef('Channel'), ForwardRef('Transport')], *args: Union[str, int], **kwargs: Dict[str, Union[str, int]]) -> Any</span>
<span>def <span class="ident">get_prompt</span></span>(<span>channel_or_transport: Union[ForwardRef('Channel'), ForwardRef('Transport')], *args: Any, **kwargs: Dict[str, Union[str, int]]) -> Any</span>
</code></dt>
<dd>
<div class="desc"></div>
Expand All @@ -661,7 +661,7 @@ <h3>Methods</h3>
</summary>
<pre><code class="python">def timeout_wrapper(
channel_or_transport: Union[&#34;Channel&#34;, &#34;Transport&#34;],
*args: Union[str, int],
*args: Any,
**kwargs: Dict[str, Union[str, int]],
) -&gt; Any:
# import here to avoid circular dependency
Expand All @@ -688,22 +688,26 @@ <h3>Methods</h3>
session_lock = channel_or_transport.session_lock
close = channel_or_transport.close

pool = ThreadPoolExecutor(max_workers=1)
future = pool.submit(wrapped_func, channel_or_transport, *args, **kwargs)
wait([future], timeout=timeout_duration)
if not future.done():
pool = multiprocessing.pool.ThreadPool(processes=1)
func_args = [channel_or_transport, *args]
future = pool.apply_async(wrapped_func, func_args, kwargs)
try:
result = future.get(timeout=timeout_duration)
pool.terminate()
return result
except multiprocessing.context.TimeoutError:
pool.terminate()
channel_or_transport.logger.info(message)
if timeout_exit:
channel_or_transport.logger.info(&#34;timeout_exit is True, closing transport&#34;)
if session_lock.locked():
session_lock.release()
close()
raise TimeoutError(message)
return future.result()</code></pre>
raise ScrapliTimeout(message)</code></pre>
</details>
</dd>
<dt id="scrapli.channel.channel.Channel.send_input"><code class="name flex">
<span>def <span class="ident">send_input</span></span>(<span>self, channel_input: str, strip_prompt: bool = True) -> Tuple[str, str]</span>
<span>def <span class="ident">send_input</span></span>(<span>self, channel_input: str, strip_prompt: bool = True) -> Tuple[bytes, bytes]</span>
</code></dt>
<dd>
<div class="desc"><p>Primary entry point to send data to devices in shell mode; accept input and returns result</p>
Expand All @@ -730,7 +734,7 @@ <h2 id="raises">Raises</h2>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def send_input(self, channel_input: str, strip_prompt: bool = True,) -&gt; Tuple[str, str]:
<pre><code class="python">def send_input(self, channel_input: str, strip_prompt: bool = True) -&gt; Tuple[bytes, bytes]:
&#34;&#34;&#34;
Primary entry point to send data to devices in shell mode; accept input and returns result

Expand All @@ -750,11 +754,11 @@ <h2 id="raises">Raises</h2>
raw_result, processed_result = self._send_input(
channel_input=channel_input, strip_prompt=strip_prompt
)
return raw_result.decode(), processed_result.decode()</code></pre>
return raw_result, processed_result</code></pre>
</details>
</dd>
<dt id="scrapli.channel.channel.Channel.send_inputs_interact"><code class="name flex">
<span>def <span class="ident">send_inputs_interact</span></span>(<span>channel_or_transport: Union[ForwardRef('Channel'), ForwardRef('Transport')], *args: Union[str, int], **kwargs: Dict[str, Union[str, int]]) -> Any</span>
<span>def <span class="ident">send_inputs_interact</span></span>(<span>channel_or_transport: Union[ForwardRef('Channel'), ForwardRef('Transport')], *args: Any, **kwargs: Dict[str, Union[str, int]]) -> Any</span>
</code></dt>
<dd>
<div class="desc"></div>
Expand All @@ -764,7 +768,7 @@ <h2 id="raises">Raises</h2>
</summary>
<pre><code class="python">def timeout_wrapper(
channel_or_transport: Union[&#34;Channel&#34;, &#34;Transport&#34;],
*args: Union[str, int],
*args: Any,
**kwargs: Dict[str, Union[str, int]],
) -&gt; Any:
# import here to avoid circular dependency
Expand All @@ -791,18 +795,22 @@ <h2 id="raises">Raises</h2>
session_lock = channel_or_transport.session_lock
close = channel_or_transport.close

pool = ThreadPoolExecutor(max_workers=1)
future = pool.submit(wrapped_func, channel_or_transport, *args, **kwargs)
wait([future], timeout=timeout_duration)
if not future.done():
pool = multiprocessing.pool.ThreadPool(processes=1)
func_args = [channel_or_transport, *args]
future = pool.apply_async(wrapped_func, func_args, kwargs)
try:
result = future.get(timeout=timeout_duration)
pool.terminate()
return result
except multiprocessing.context.TimeoutError:
pool.terminate()
channel_or_transport.logger.info(message)
if timeout_exit:
channel_or_transport.logger.info(&#34;timeout_exit is True, closing transport&#34;)
if session_lock.locked():
session_lock.release()
close()
raise TimeoutError(message)
return future.result()</code></pre>
raise ScrapliTimeout(message)</code></pre>
</details>
</dd>
</dl>
Expand Down
Loading

0 comments on commit 389c73f

Please sign in to comment.