Skip to content

Commit

Permalink
few minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
carlmontanari committed Jul 12, 2020
1 parent a0144ab commit d07b846
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 17 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
CHANGELOG
=========

# 2020.XX.XX
# 2020.07.12
- Minor improvements to response recording (should be a tick faster)
- Update decorators for async things to use the improved `async_operation_timeout` in scrapli 2020.07.12
- Set `strip_namespaces` to `False` for `AsyncNetconfScrape` for consistency/sanity
- Update a few dev pins, update required pins to ensure no major lxml updates break things

# 2020.07.04
- First real release??? :)

# 2020.04.19
- Initial pypi release... very beta still
- Initial pypi release... very beta still
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,13 @@ cov_unit:
--cov=scrapli_netconf \
--cov-report html \
--cov-report term \
tests/unit/
tests/unit/

test:
python -m pytest tests/

test_unit:
python -m pytest tests/unit/

test_functional:
python -m pytest tests/functional/
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pylama>=7.7.1
pycodestyle>=2.6.0
pydocstyle>=5.0.2
pylint>=2.5.3
darglint>=1.4.1
pdoc3>=0.8.1 ; sys_platform != "win32"
darglint>=1.5.1
pdoc3>=0.8.3 ; sys_platform != "win32"
-e git+https://github.com/scrapli/scrapli_stubs@master#egg=scrapli_stubs
-r requirements.txt
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scrapli>=2020.07.04
scrapli>=2020.07.12
scrapli_asyncssh>=2020.07.04
lxml>=4.5.1
lxml>=4.5.1,<5.0.0
6 changes: 3 additions & 3 deletions scrapli_netconf/channel/async_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Any, Optional

from scrapli.channel import AsyncChannel
from scrapli.decorators import operation_timeout
from scrapli.decorators import async_operation_timeout
from scrapli.transport.async_transport import AsyncTransport
from scrapli_netconf.channel.base_channel import NetconfChannelBase
from scrapli_netconf.constants import NetconfVersion
Expand All @@ -19,7 +19,7 @@ def __init__(self, transport: AsyncTransport, **kwargs: Any):
self.netconf_version = NetconfVersion.VERSION_1_0
self._server_echo = False

@operation_timeout(
@async_operation_timeout(
"timeout_ops",
"Timed out determining if session is authenticated/getting server capabilities",
)
Expand All @@ -45,7 +45,7 @@ async def _get_server_capabilities(self, login_bytes: bytes) -> bytes:
self.transport.session_lock.release()
return output

@operation_timeout("timeout_ops", "Timed out sending client capabilities")
@async_operation_timeout("timeout_ops", "Timed out sending client capabilities")
async def _send_client_capabilities(
self,
client_capabilities: NetconfClientCapabilities,
Expand Down
2 changes: 1 addition & 1 deletion scrapli_netconf/driver/async_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AsyncNetconfScrape(AsyncScrape, NetconfScrapeBase):
def __init__(
self,
port: int = 830,
strip_namespaces: bool = True,
strip_namespaces: bool = False,
strict_datastores: bool = False,
**kwargs: Any,
) -> None:
Expand Down
8 changes: 3 additions & 5 deletions scrapli_netconf/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ def _record_response_netconf_1_0(self) -> None:
self.result = etree.tostring(self.xml_result).decode()

if self.strip_namespaces:
xml_result = etree.fromstring(self.result)
self.xml_result = remove_namespaces(xml_result)
self.xml_result = remove_namespaces(self.xml_result)
self.result = etree.tostring(self.xml_result).decode()

def _record_response_netconf_1_1(self) -> None:
Expand Down Expand Up @@ -160,16 +159,15 @@ def _record_response_netconf_1_1(self) -> None:
[
# remove the message end characters and xml document header see:
# https://github.com/scrapli/scrapli_netconf/issues/1
result[1].replace(b'<?xml version="1.0" encoding="UTF-8"?>', b"").rstrip()
result[1].replace(b'<?xml version="1.0" encoding="UTF-8"?>', b"")
for result in result_sections
]
)
)
self.result = etree.tostring(self.xml_result).decode()

if self.strip_namespaces:
xml_result = etree.fromstring(self.result)
self.xml_result = remove_namespaces(xml_result)
self.xml_result = remove_namespaces(self.xml_result)
self.result = etree.tostring(self.xml_result).decode()

def get_xml_elements(self) -> Dict[str, Element]:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setuptools.setup(
name="scrapli_netconf",
version="2020.07.04",
version="2020.07.12",
author=__author__,
author_email="[email protected]",
description="Netconf driver built on scrapli",
Expand Down

0 comments on commit d07b846

Please sign in to comment.