From 07c6db63943f899ce0726150bb1fd20c21315138 Mon Sep 17 00:00:00 2001 From: mpenning Date: Sun, 9 Jul 2023 19:40:36 -0500 Subject: [PATCH 01/27] Adjust 'backup' target to exclude the bin/ directory --- dev_tools/deploy_docs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev_tools/deploy_docs/Makefile b/dev_tools/deploy_docs/Makefile index 7ad278fb..d4d45a86 100644 --- a/dev_tools/deploy_docs/Makefile +++ b/dev_tools/deploy_docs/Makefile @@ -74,6 +74,6 @@ backup: # Delete backups older than 30 days... dont crash if directory is empty -find ./_bak/*tgz -maxdepth 1 -type f -mtime +30 -delete # Create a timestamped backup tarball... exclude the _bak directory - tar --exclude=_bak -zcv -f _bak/$(shell date "+%Y%m%d_%H.%M.%S").tgz . + tar -zcv -f _bak/$(shell date "+%Y%m%d_%H.%M.%S").tgz --exclude='_bak/*' --exclude='bin/*' . .PHONY: backup From 8ec2236d7a92629cc897a09c76cf862adbe5fcaa Mon Sep 17 00:00:00 2001 From: mpenning Date: Tue, 11 Jul 2023 08:22:27 -0500 Subject: [PATCH 02/27] Sync with github version --- CHANGES.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 7e1a0660..aa456805 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,12 @@ - Summary: - Insert something here +## Version: 1.7.25 + +- Released: 2023-07-10 +- Summary: + - Rewrite `dev_tools/deploy_docs.py` in go to avoid hassles with python's `fabric.api`. + ## Version: 1.7.24 - Released: 2023-05-13 @@ -12,11 +18,17 @@ - Attempt to reduce packaging clutter in pyproject.toml [include] - Fix Github Issue #275: Roll back to hard-coded dependencies in pyproject.toml +## Version: 1.7.23 + +- Released: 2023-05-12 +- Summary: + - This release was yanked from pypi. See Github Issue #277 for details. ## Version: 1.7.22 - Released: 2023-05-12 - Summary: + - This release was yanked from pypi. See Github Issue #277 for details. - Add new imports to `tests/conftest.py`. All tests under 1.7.21 and earlier pass (from py3.7 to py3.11) except for py3.10. The error is failing dnspython imports. See Github Issue #274. ## Version: 1.7.21 @@ -1779,3 +1791,5 @@ - Summary: - Revised APIs - Existing APIs should be stable now + + From fabbb47c1846861c89b27e6f4c96b4a2093e2c46 Mon Sep 17 00:00:00 2001 From: mpenning Date: Wed, 20 Sep 2023 06:15:10 -0500 Subject: [PATCH 03/27] Initial commit --- dev_tools/deploy_docs/src/deploy_docs.go | 47 ++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 dev_tools/deploy_docs/src/deploy_docs.go diff --git a/dev_tools/deploy_docs/src/deploy_docs.go b/dev_tools/deploy_docs/src/deploy_docs.go new file mode 100644 index 00000000..c152ff1b --- /dev/null +++ b/dev_tools/deploy_docs/src/deploy_docs.go @@ -0,0 +1,47 @@ +package main + +import ( + "github.com/gleich/logoru" + "github.com/melbahja/goph" +) + +func main() { + + logoru.Info("Starting Documentation build") + + logoru.Info("Starting CiscoConfParse new documentation upload") + + logoru.Info(" Initialize ssh key-auth") + // Start new ssh connection with private key. + auth, err := goph.Key("/home/mpenning/.ssh/id_ed25519", "") + if err != nil { + logoru.Critical(err.Error()) + } + + logoru.Debug(" ssh into remote webhost") + client, err := goph.New("mpenning", "chestnut.he.net", auth) + if err != nil { + logoru.Critical(err.Error()) + } + + logoru.Debug(" Remove old documentation files") + _, err = client.Run("bash -c 'cd public_html/py/ciscoconfparse/ && rm -rf *'") + if err != nil { + logoru.Critical(err.Error()) + } + + logoru.Info(" Start copying doc tarball to remote ssh server") + err = client.Upload("/home/mpenning/ccp.tar.gz", "public_html/py/ciscoconfparse/ccp.tar.gz") + if err != nil { + logoru.Critical(err.Error()) + } + logoru.Info(" Finished copying tarball to remote ssh server") + + logoru.Info(" extract CiscoConfParse documentation tarball") + _, err = client.Run("bash -c 'cd public_html/py/ciscoconfparse/ && tar xvfz ./ccp.tar.gz'") + if err != nil { + logoru.Critical(err.Error()) + } + + // NOT_NEEDED -> defer client.Close() +} From b3156ab12b77e324a4926b0892287cbcb9ffe349 Mon Sep 17 00:00:00 2001 From: mpenning Date: Wed, 20 Sep 2023 06:15:49 -0500 Subject: [PATCH 04/27] Remove old filename after rename --- dev_tools/deploy_docs/deploy_docs.go | 51 ---------------------------- 1 file changed, 51 deletions(-) delete mode 100644 dev_tools/deploy_docs/deploy_docs.go diff --git a/dev_tools/deploy_docs/deploy_docs.go b/dev_tools/deploy_docs/deploy_docs.go deleted file mode 100644 index a74cc6d6..00000000 --- a/dev_tools/deploy_docs/deploy_docs.go +++ /dev/null @@ -1,51 +0,0 @@ -package main - -import ( - "github.com/melbahja/goph" - // zap provides useful logging... - "go.uber.org/zap" - "go.uber.org/zap/zapcore" -) - -func main() { - - logconfig := zap.NewDevelopmentConfig() - logconfig.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder - logger, _ := logconfig.Build() - - logger.Info("Starting CiscoConfParse new documentation upload") - - logger.Info(" Initialize ssh key-auth") - // Start new ssh connection with private key. - auth, err := goph.Key("/home/mpenning/.ssh/id_ed25519", "") - if err != nil { - logger.Fatal(err.Error()) - } - - logger.Info(" ssh into remote webhost") - client, err := goph.New("mpenning", "chestnut.he.net", auth) - if err != nil { - logger.Fatal(err.Error()) - } - - logger.Info(" Remove old documentation files") - _, err = client.Run("bash -c 'cd public_html/py/ciscoconfparse/ && rm -rf *'") - if err != nil { - logger.Fatal(err.Error()) - } - - logger.Info(" Start copying doc tarball to remote ssh server") - err = client.Upload("/home/mpenning/ccp.tar.gz", "public_html/py/ciscoconfparse/ccp.tar.gz") - if err != nil { - logger.Fatal(err.Error()) - } - logger.Info(" Finished copying tarball to remote ssh server") - - logger.Info(" extract CiscoConfParse documentation tarball") - _, err = client.Run("bash -c 'cd public_html/py/ciscoconfparse/ && tar xvfz ./ccp.tar.gz'") - if err != nil { - logger.Fatal(err.Error()) - } - - // NOT_NEEDED -> defer client.Close() -} From 34e2ce0abf28d511e05751549ad6d77d830ebdef Mon Sep 17 00:00:00 2001 From: mpenning Date: Wed, 20 Sep 2023 06:21:27 -0500 Subject: [PATCH 05/27] Remove zapcore, & move deploy_docs.go to src/ dir --- dev_tools/deploy_docs/Makefile | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/dev_tools/deploy_docs/Makefile b/dev_tools/deploy_docs/Makefile index d4d45a86..b1acb96c 100644 --- a/dev_tools/deploy_docs/Makefile +++ b/dev_tools/deploy_docs/Makefile @@ -8,12 +8,21 @@ COL_YELLOW=\033[0;33m COL_RED=\033[0;31m COL_END=\033[0;0m +GOOS=linux + # Good primer on Makefile variables... # https://earthly.dev/blog/makefile-variables/ -GO_SOURCE_FILE=deploy_docs.go +GO_SOURCE_FILE=src/deploy_docs.go .DEFAULT_GOAL := build +# 'make release' will perform the ultimate binary packing (sometimes +# resulting in a 70% smaller binary!!!); however, 'upx' is really slow +release: + make build + upx --ultra-brute bin/deploy_docs +.PHONY: release + # Ref -> https://stackoverflow.com/a/26737258/667301 build: @echo "$(COL_GREEN)>> compiling the project.$(COL_END)" @@ -21,15 +30,13 @@ build: make backup make fmt make dep - make lint - go build $(GO_SOURCE_FILE) - strip deploy_docs + -make lint + go build -o bin/deploy_docs -ldflags="-s -w" $(GO_SOURCE_FILE) .PHONY: build fmt: @echo "$(COL_GREEN)>> reformatting with 'go fmt'$(COL_END)" - go fmt $(GO_SOURCE_FILE) > $(GO_SOURCE_FILE).fmt - mv $(GO_SOURCE_FILE).fmt $(GO_SOURCE_FILE) + go fmt $(GO_SOURCE_FILE) .PHONY: fmt install_linters: @@ -54,16 +61,16 @@ lint: @echo "$(COL_CYAN)>> running gocritic$(COL_END)" gocritic check -enableAll $(GO_SOURCE_FILE) @echo "$(COL_CYAN)>> running staticcheck$(COL_END)" - staticcheck . + staticcheck src/*go @echo "$(COL_CYAN)>> running errcheck$(COL_END)" errcheck -verbose $(GO_SOURCE_FILE) .PHONY: lint dep: @echo "$(COL_GREEN)>> getting deploy_docs dependencies$(COL_END)" + go mod tidy go get github.com/melbahja/goph@latest - go get go.uber.org/zap - go get go.uber.org/zap/zapcore + go get github.com/gleich/logoru@latest .PHONY: dep backup: @@ -74,6 +81,11 @@ backup: # Delete backups older than 30 days... dont crash if directory is empty -find ./_bak/*tgz -maxdepth 1 -type f -mtime +30 -delete # Create a timestamped backup tarball... exclude the _bak directory - tar -zcv -f _bak/$(shell date "+%Y%m%d_%H.%M.%S").tgz --exclude='_bak/*' --exclude='bin/*' . + tar --exclude=bin --exclude=_bak -zcv -f _bak/$(shell date "+%Y%m%d_%H.%M.%S").tgz . .PHONY: backup +clean: + @echo "$(COL_GREEN)>> cleaning up bin/deploy_docs and other build artifacts.$(COL_END)" + # Delete this binary because it's just huge and we can rebuild from src... + -rm -rf bin/ +.PHONY: clean From 17449c61071a77a9fd98bde1c6f0dcaece88c5dd Mon Sep 17 00:00:00 2001 From: mpenning Date: Sat, 30 Sep 2023 17:49:47 -0500 Subject: [PATCH 06/27] Bump loguru to 0.7.2 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 253f7b1b..d2fd9b49 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ # Also ref Github Issue #257 poetry == 1.5.1 poetry-core == 1.6.1 -loguru == 0.7.0 +loguru == 0.7.2 passlib == 1.7.4 toml > 0.10.1 dnspython == 2.2.1 From 28e5e77374adf7c85d887a1d524cb1a9c2a61033 Mon Sep 17 00:00:00 2001 From: mpenning Date: Sat, 30 Sep 2023 17:54:16 -0500 Subject: [PATCH 07/27] Comment out better-exceptions --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d2fd9b49..3f849de5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,5 +6,5 @@ loguru == 0.7.2 passlib == 1.7.4 toml > 0.10.1 dnspython == 2.2.1 -better_exceptions == 0.3.3 deprecat == 2.1.1 +#better_exceptions == 0.3.3 From 767925cd0045ddac60501c4f7d501c2180ab354a Mon Sep 17 00:00:00 2001 From: mpenning Date: Sat, 30 Sep 2023 17:55:18 -0500 Subject: [PATCH 08/27] Remove better_exceptions --- ciscoconfparse/__init__.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ciscoconfparse/__init__.py b/ciscoconfparse/__init__.py index 13860566..e6a45fef 100644 --- a/ciscoconfparse/__init__.py +++ b/ciscoconfparse/__init__.py @@ -26,11 +26,10 @@ import sys - -import better_exceptions -better_exceptions.MAX_LENGTH = None -better_exceptions.SUPPORTS_COLOR = True -better_exceptions.hook() +if False: + better_exceptions.MAX_LENGTH = None + better_exceptions.SUPPORTS_COLOR = True + better_exceptions.hook() from ciscoconfparse.ccp_util import PythonOptimizeCheck from ciscoconfparse.ciscoconfparse import * From 7c0ce2312dbc1766b9569688c9e7c004d1385a88 Mon Sep 17 00:00:00 2001 From: mpenning Date: Sun, 8 Oct 2023 14:10:05 -0500 Subject: [PATCH 09/27] Bump dependency versions as-required --- requirements.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 3f849de5..80230880 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,9 @@ # Ensure wheel is upgraded to fix CVE-2022-40898 # Also ref Github Issue #257 -poetry == 1.5.1 -poetry-core == 1.6.1 +poetry == 1.6.1 loguru == 0.7.2 passlib == 1.7.4 toml > 0.10.1 -dnspython == 2.2.1 +dnspython == 2.4.2 deprecat == 2.1.1 #better_exceptions == 0.3.3 From 32ec8ed042701eb79bdc71f0e19926f56cb32abc Mon Sep 17 00:00:00 2001 From: mpenning Date: Sun, 8 Oct 2023 14:25:51 -0500 Subject: [PATCH 10/27] Migrate from deprecat import to deprecated import --- ciscoconfparse/ciscoconfparse.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ciscoconfparse/ciscoconfparse.py b/ciscoconfparse/ciscoconfparse.py index 988378c3..4531c41e 100644 --- a/ciscoconfparse/ciscoconfparse.py +++ b/ciscoconfparse/ciscoconfparse.py @@ -91,7 +91,7 @@ # Not using ccp_re yet... still a work in progress # from ciscoconfparse.ccp_util import ccp_re -from deprecat import deprecat +from deprecated import deprecated from loguru import logger import toml @@ -3119,7 +3119,7 @@ def re_match_iter_typed( # This method is on CiscoConfParse() @logger.catch(reraise=True) - @deprecat( + @deprecated( reason="req_cfgspec_all_diff() is obsolete; use HDiff() instead. req_cfgspec_all_diff() will be removed", version="1.7.0", ) @@ -3191,7 +3191,7 @@ def req_cfgspec_all_diff(self, cfgspec, ignore_ws=False): # This method is on CiscoConfParse() @logger.catch(reraise=True) - @deprecat( + @deprecated( reason="req_cfgspec_excl_diff() is obsolete; use HDiff() instead. req_cfgspec_excl_diff() will be removed", version="1.7.0", ) From 43318cffb2f4e37e021b03849a0cdbccd7b25e07 Mon Sep 17 00:00:00 2001 From: mpenning Date: Sun, 8 Oct 2023 14:26:02 -0500 Subject: [PATCH 11/27] Migrate from deprecat import to deprecated import --- ciscoconfparse/ccp_util.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ciscoconfparse/ccp_util.py b/ciscoconfparse/ccp_util.py index 63f36ea3..2e875fed 100644 --- a/ciscoconfparse/ccp_util.py +++ b/ciscoconfparse/ccp_util.py @@ -44,7 +44,7 @@ from dns.resolver import Resolver from dns import reversename, query, zone -from deprecat import deprecat +from deprecated import deprecated from loguru import logger @@ -2794,7 +2794,7 @@ def dns_query(input_str="", query_type="", server="", timeout=2.0): @logger.catch(reraise=True) -@deprecat(reason="dns_lookup() is obsolete; use dns_query() instead. dns_lookup() will be removed", version='1.7.0') +@deprecated(reason="dns_lookup() is obsolete; use dns_query() instead. dns_lookup() will be removed", version='1.7.0') def dns_lookup(input_str, timeout=3, server="", record_type="A"): """Perform a simple DNS lookup, return results in a dictionary""" if not isinstance(input_str, str): @@ -2848,7 +2848,7 @@ def dns_lookup(input_str, timeout=3, server="", record_type="A"): @logger.catch(reraise=True) -@deprecat(reason="dns6_lookup() is obsolete; use dns_query() instead. dns6_lookup() will be removed", version='1.7.0') +@deprecated(reason="dns6_lookup() is obsolete; use dns_query() instead. dns6_lookup() will be removed", version='1.7.0') def dns6_lookup(input_str, timeout=3, server=""): """Perform a simple DNS lookup, return results in a dictionary""" rr = Resolver() @@ -2907,7 +2907,7 @@ def check_valid_ipaddress(input_addr=None): @logger.catch(reraise=True) -@deprecat(reason="reverse_dns_lookup() is obsolete; use dns_query() instead. reverse_dns_lookup() will be removed", version='1.7.0') +@deprecated(reason="reverse_dns_lookup() is obsolete; use dns_query() instead. reverse_dns_lookup() will be removed", version='1.7.0') def reverse_dns_lookup(input_str, timeout=3.0, server="4.2.2.2", proto="udp"): """Perform a simple reverse DNS lookup on an IPv4 or IPv6 address; return results in a python dictionary""" if not isinstance(proto, str) and (proto=="udp" or proto=="tcp"): From d12eba82a2feb81fba58dcba6997507270d04913 Mon Sep 17 00:00:00 2001 From: mpenning Date: Sun, 8 Oct 2023 14:27:44 -0500 Subject: [PATCH 12/27] Bump version to 1.8.0 --- pyproject.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4e2f5964..8b0ab1f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ requires-python = ">=3.7.0" [tool.poetry] name = "ciscoconfparse" -version = "1.7.25" +version = "1.8.0" description = "Parse, Audit, Query, Build, and Modify Cisco IOS-style and JunOS-style configs" license = "GPL-3.0-only" authors = [ @@ -78,11 +78,11 @@ classifiers=[ [tool.poetry.dependencies] python = ">=3.7.2,<4.0.0" passlib = "^1.7.4" -dnspython = "^2.2.0" -loguru = "0.7.0" +dnspython = "^2.4.2" +loguru = "0.7.2" toml = ">=0.10.2" -deprecat = "2.1.1" -better_exceptions = "0.3.3" +deprecated = "1.2.14" +better_exceptions = "0.2.1" [tool.poetry.urls] source = "https://github.com/mpenning/ciscoconfparse" From 13ebef65a87424eb9c497ec952829fc6a097c6f3 Mon Sep 17 00:00:00 2001 From: mpenning Date: Sun, 8 Oct 2023 14:30:12 -0500 Subject: [PATCH 13/27] Add Dependencies section --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index c879e139..e7811576 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,17 @@ copies of CiscoConfParse source-code must also be licensed as GPLv3][45]. Dear [Cisco Systems][27]: please consider porting your improvements back into the [`github ciscoconfparse repo`](https://github.com/mpenning/ciscoconfparse). +Dependencies +------------ + +- [Python 3](https://python.org/) +- [passlib](https://github.com/glic3rinu/passlib) +- [toml](https://github.com/uiri/toml) +- [dnspython](https://github.com/rthalley/dnspython) +- [loguru](https://github.com/Delgan/loguru) +- [deprecated](https://github.com/tantale/deprecated) +- [better-exceptions](https://github.com/Qix-/better-exceptions) + Is this a tool, or is it artwork? --------------------------------- From e006e119518fc9e0d9137dc5efb18619a46ebe29 Mon Sep 17 00:00:00 2001 From: mpenning Date: Sun, 8 Oct 2023 14:30:55 -0500 Subject: [PATCH 14/27] Migrate to deprecated import and move to different better_exceptions ver --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 80230880..407e00e4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,5 +5,5 @@ loguru == 0.7.2 passlib == 1.7.4 toml > 0.10.1 dnspython == 2.4.2 -deprecat == 2.1.1 -#better_exceptions == 0.3.3 +deprecated == 1.2.14 +better_exceptions == 0.2.1 From dbaf0f46019be279938b39a07d4f7a0b2575e1f4 Mon Sep 17 00:00:00 2001 From: mpenning Date: Sun, 8 Oct 2023 14:31:46 -0500 Subject: [PATCH 15/27] Add more tests --- tests/test_Ccp_Util.py | 69 +++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 25 deletions(-) diff --git a/tests/test_Ccp_Util.py b/tests/test_Ccp_Util.py index e7b6390b..3e74353f 100755 --- a/tests/test_Ccp_Util.py +++ b/tests/test_Ccp_Util.py @@ -226,6 +226,14 @@ def testIPv4Obj_set_masklen01(): assert test_object.prefixlen == result_correct_masklen assert test_object.prefixlength == result_correct_masklen +def testIPv4Obj_network_offset(): + test_object = IPv4Obj("192.0.2.28/24") + assert test_object.network_offset == 28 + +def testIPv4Obj_set_network_offset(): + test_object = IPv4Obj("192.0.2.28/24") + test_object.network_offset = 200 + assert test_object == IPv4Obj("192.0.2.200/24") def testIPv4Obj_attributes_01(): ## Ensure that attributes are accessible and pass the smell test @@ -251,9 +259,10 @@ def testIPv4Obj_attributes_01(): ("netmask", IPv4Address("255.255.255.0")), ("network", IPv4Network("1.0.0.0/24")), ("network_object", IPv4Network("1.0.0.0/24")), + ("network_offset", 1), ("prefixlen", 24), ("prefixlength", 24), - ("numhosts", 256), + ("numhosts", 254), ("version", 4), ] for attribute, result_correct in results_correct: @@ -333,32 +342,10 @@ def test_ip_factory_inputs_02(): with pytest.raises(ipaddress.AddressValueError): ip_factory("FE80:AAAA::DEAD:BEEEEEEEEEEF", stdlib=False, mode="auto_detect") - -def testIPv6Obj_attributes(): +def testIPv6Obj_attributes_01(): ## Ensure that attributes are accessible and pass the smell test test_object = IPv6Obj("2001::dead:beef/64") results_correct = [ - ("ip", IPv6Address("2001::dead:beef")), - ("ip_object", IPv6Address("2001::dead:beef")), - ("netmask", IPv6Address("ffff:ffff:ffff:ffff::")), - ("prefixlen", 64), - ("network", IPv6Network("2001::/64")), - ("network_object", IPv6Network("2001::/64")), - ("hostmask", IPv6Address("::ffff:ffff:ffff:ffff")), - ("numhosts", 18446744073709551616), - ("version", 6), - ("is_reserved", False), - ("is_multicast", False), - # ("is_private", False), # FIXME: disabling this for now... - # py2.7 and py3.x produce different results - ("as_cidr_addr", "2001::dead:beef/64"), - ("as_cidr_net", "2001::/64"), - ("as_decimal", 42540488161975842760550356429036175087), - ("as_decimal_network", 42540488161975842760550356425300246528), - ( - "as_hex_tuple", - ("2001", "0000", "0000", "0000", "0000", "0000", "dead", "beef"), - ), ( "as_binary_tuple", ( @@ -372,10 +359,42 @@ def testIPv6Obj_attributes(): "1011111011101111", ), ), + ("as_cidr_addr", "2001::dead:beef/64"), + ("as_cidr_net", "2001::/64"), + ("as_decimal", 42540488161975842760550356429036175087), + ("as_decimal_network", 42540488161975842760550356425300246528), + ("ip", IPv6Address("2001::dead:beef")), + ("ip_object", IPv6Address("2001::dead:beef")), + ("netmask", IPv6Address("ffff:ffff:ffff:ffff::")), + ("prefixlen", 64), + ("network", IPv6Network("2001::/64")), + ("network_object", IPv6Network("2001::/64")), + ("network_offset", 3735928559), + ("hostmask", IPv6Address("::ffff:ffff:ffff:ffff")), + ("numhosts", 18446744073709551614), + ("version", 6), + ("is_multicast", False), + ("is_link_local", False), + ("is_private", True), + ("is_reserved", False), + ("is_site_local", False), + ( + "as_hex_tuple", + ("2001", "0000", "0000", "0000", "0000", "0000", "dead", "beef"), + ), ] for attribute, result_correct in results_correct: assert getattr(test_object, attribute) == result_correct + +def testIPv6Obj_network_offset_01(): + test_object = IPv6Obj("2001::dead:beef/64") + assert test_object.network_offset == 3735928559 + +def testIPv6Obj_set_network_offset_01(): + test_object = IPv6Obj("2001::dead:beef/64") + test_object.network_offset = 200 + assert test_object == IPv6Obj("2001::c8/64") def testIPv4Obj_sort_01(): @@ -587,7 +606,7 @@ def test_collapse_addresses_02(): def test_dns_lookup(): # Use my hostname to test... - test_hostname = "www.pennington.net" + test_hostname = "pennington.net" result_correct_address = "65.19.187.2" result_correct = {"addrs": [result_correct_address], "name": test_hostname, "error": "", "record_type": "A"} try: From 74679bad6b1bd50d7b0347ab747d66d6dd7dbaab Mon Sep 17 00:00:00 2001 From: mpenning Date: Sun, 8 Oct 2023 14:32:17 -0500 Subject: [PATCH 16/27] Reformat some test results --- tests/test_CiscoConfParse.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_CiscoConfParse.py b/tests/test_CiscoConfParse.py index 0954a29c..c3b1140d 100644 --- a/tests/test_CiscoConfParse.py +++ b/tests/test_CiscoConfParse.py @@ -2832,9 +2832,15 @@ def test_ios_blank_line_01(): syntax="ios", ignore_blank_lines=True, ) - parse.find_parents_w_child(parentspec="interface\s+Giga", childspec=" logging event link-status") - parse.find_parents_w_child(parentspec="interface\s+Giga", childspec=" logging event bundle-status") - parse.find_parents_w_child(parentspec="interface\s+Giga", childspec=" logging event spanning-tree") + + result_01 = parse.find_parents_w_child(parentspec="interface\s+Giga", childspec=" logging event link-status") + assert len(result_01) == 1 + + result_02 = parse.find_parents_w_child(parentspec="interface\s+Giga", childspec=" logging event bundle-status") + assert len(result_02) == 1 + + result_03 = parse.find_parents_w_child(parentspec="interface\s+Giga", childspec=" logging event spanning-tree") + assert len(result_03) == 1 def test_has_line_with_all_syntax(): From 07017351f1df29931bb766bd570783bd8335b3f2 Mon Sep 17 00:00:00 2001 From: mpenning Date: Sun, 8 Oct 2023 14:37:20 -0500 Subject: [PATCH 17/27] Remove some disabled test assertions --- tests/test_Models_Cisco.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/tests/test_Models_Cisco.py b/tests/test_Models_Cisco.py index 5b75185f..36aa2bd6 100755 --- a/tests/test_Models_Cisco.py +++ b/tests/test_Models_Cisco.py @@ -337,7 +337,7 @@ def testVal_IOSIntfLine_trunk_vlan_allowed_05(): ] cfg = CiscoConfParse(lines, factory=True) intf_obj = cfg.find_objects("^interface")[0] - assert intf_obj.trunk_vlans_allowed.as_list == [1] + assert intf_obj.trunk_vlans_allowed.as_list == [1,] def testVal_IOSIntfLine_trunk_vlan_allowed_06(): @@ -1057,17 +1057,20 @@ def testVal_IOSIntfLine_ipv4_addr_object01(parse_c03_factory): result_correct = { "interface Serial 1/0": IPv4Obj("1.1.1.1/30", strict=False), "interface Serial 1/1": IPv4Obj("1.1.1.9/31", strict=False), - "interface GigabitEthernet4/1": IPv4Obj("127.0.0.1/32", strict=False), - "interface GigabitEthernet4/2": IPv4Obj("127.0.0.1/32", strict=False), - "interface GigabitEthernet4/3": IPv4Obj("127.0.0.1/32", strict=False), - "interface GigabitEthernet4/4": IPv4Obj("127.0.0.1/32", strict=False), - "interface GigabitEthernet4/5": IPv4Obj("127.0.0.1/32", strict=False), - "interface GigabitEthernet4/6": IPv4Obj("127.0.0.1/32", strict=False), - "interface GigabitEthernet4/7": IPv4Obj("127.0.0.1/32", strict=False), + "interface GigabitEthernet4/1": IPv4Obj("0.0.0.1/32", strict=False), + "interface GigabitEthernet4/2": IPv4Obj("0.0.0.1/32", strict=False), + "interface GigabitEthernet4/3": IPv4Obj("0.0.0.1/32", strict=False), + "interface GigabitEthernet4/4": IPv4Obj("0.0.0.1/32", strict=False), + "interface GigabitEthernet4/5": IPv4Obj("0.0.0.1/32", strict=False), + "interface GigabitEthernet4/6": IPv4Obj("0.0.0.1/32", strict=False), + "interface GigabitEthernet4/7": IPv4Obj("0.0.0.1/32", strict=False), "interface GigabitEthernet4/8.120": IPv4Obj("1.1.2.254/24", strict=False), - "interface ATM5/0/0": IPv4Obj("127.0.0.1/32", strict=False), + "interface ATM5/0/0": IPv4Obj("0.0.0.1/32", strict=False), "interface ATM5/0/0.32 point-to-point": IPv4Obj("1.1.1.5/30", strict=False), - "interface ATM5/0/1": IPv4Obj("127.0.0.1/32", strict=False), + "interface ATM5/0/1": IPv4Obj("0.0.0.1/32", strict=False), + + # FIXME FIXME FIXME + #"interface ATM5/0/1": None, } test_result = dict() ## Parse all interface objects in c01 and check ipv4_addr_object @@ -1085,8 +1088,10 @@ def testVal_IOSIntfLine_ipv4_addr_object02(): "!", ] cfg = CiscoConfParse(lines, factory=True) - with pytest.raises(DynamicAddressException): - cfg.find_objects("^interface")[0].ipv4_addr_object + # NOTE - Due to infinite error recursion I used to throw an + # DynamicAddressException() here but had to stop due to infinite + # error recursion here... + assert cfg.find_objects("^interface")[0].ipv4_addr_object == IPv4Obj("0.0.0.1/32") def testVal_IOSIntfLine_ip_network_object01(): @@ -1098,9 +1103,11 @@ def testVal_IOSIntfLine_ip_network_object01(): "!", ] cfg = CiscoConfParse(lines, factory=True) - with pytest.raises(DynamicAddressException): - cfg.find_objects("^interface")[0].ip_network_object + # NOTE - Due to infinite error recursion I used to throw an + # DynamicAddressException() here but had to stop due to infinite + # error recursion here... + assert cfg.find_objects("^interface")[0].ipv4_addr_object == IPv4Obj("0.0.0.1/32") def testVal_IOSIntfLine_has_autonegotiation(parse_c03_factory): cfg = parse_c03_factory From 801996c4569c01fab558353d5287bcfbbcf48782 Mon Sep 17 00:00:00 2001 From: mpenning Date: Sun, 8 Oct 2023 14:37:43 -0500 Subject: [PATCH 18/27] Remove some debugging --- ciscoconfparse/ccp_util.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ciscoconfparse/ccp_util.py b/ciscoconfparse/ccp_util.py index 2e875fed..a5dfed69 100644 --- a/ciscoconfparse/ccp_util.py +++ b/ciscoconfparse/ccp_util.py @@ -1250,13 +1250,6 @@ def __contains__(self, val): # return (self.network <= val.network) and ( # self.broadcast >= val.broadcast # ) - logger.debug(self.__repr__()) - logger.debug(self.as_decimal_network) - logger.debug(self.numhosts) - logger.debug("---------------------------------") - logger.debug(val.__repr__()) - logger.debug(val.as_decimal_network) - logger.debug(val.numhosts) return (self.as_decimal_network <= val.as_decimal_network) and (self.as_decimal_broadcast >= val.as_decimal_broadcast) and (self.prefixlen <= val.prefixlen) except ValueError as eee: From f1d370dbe0fdd644a98452df4683e9d5a466670e Mon Sep 17 00:00:00 2001 From: mpenning Date: Sun, 8 Oct 2023 14:42:33 -0500 Subject: [PATCH 19/27] Improve workflow --- dev_tools/deploy_docs/Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dev_tools/deploy_docs/Makefile b/dev_tools/deploy_docs/Makefile index b1acb96c..f5865fa2 100644 --- a/dev_tools/deploy_docs/Makefile +++ b/dev_tools/deploy_docs/Makefile @@ -28,12 +28,19 @@ build: @echo "$(COL_GREEN)>> compiling the project.$(COL_END)" # Very Important... do not skip the backup step here... make backup - make fmt + -make fmt make dep -make lint + cd src && go vet . go build -o bin/deploy_docs -ldflags="-s -w" $(GO_SOURCE_FILE) .PHONY: build +deploy: + make build + cd bin && ./deploy_docs + make clean +.PHONY: deploy + fmt: @echo "$(COL_GREEN)>> reformatting with 'go fmt'$(COL_END)" go fmt $(GO_SOURCE_FILE) From ca12c824fbcbd56e245ac65ccc32f2c643ba6d1c Mon Sep 17 00:00:00 2001 From: mpenning Date: Sun, 8 Oct 2023 15:18:02 -0500 Subject: [PATCH 20/27] Remove unused dependency --- dev_tools/deploy_docs/go.mod | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/dev_tools/deploy_docs/go.mod b/dev_tools/deploy_docs/go.mod index d83f5f92..b8615d39 100644 --- a/dev_tools/deploy_docs/go.mod +++ b/dev_tools/deploy_docs/go.mod @@ -1,16 +1,22 @@ -module deploy_docs.go +module deploy_docs go 1.20 require ( + github.com/gleich/logoru v0.0.0-20230101033757-d86cd895c7a1 + github.com/melbahja/goph v1.4.0 +) + +require github.com/mpenning/gorrow v0.0.0-20230930235015-e9cbafe66692 + +require ( + github.com/fatih/color v1.10.0 // indirect github.com/kr/fs v0.1.0 // indirect - github.com/melbahja/goph v1.3.1 // indirect + github.com/mattn/go-colorable v0.1.8 // indirect + github.com/mattn/go-isatty v0.0.12 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pkg/sftp v1.13.5 // indirect - github.com/sirupsen/logrus v1.9.3 // indirect - go.uber.org/atomic v1.7.0 // indirect - go.uber.org/multierr v1.6.0 // indirect - go.uber.org/zap v1.24.0 // indirect + github.com/stretchr/testify v1.8.2 // indirect golang.org/x/crypto v0.6.0 // indirect golang.org/x/sys v0.5.0 // indirect ) From becbb50c1a3c766df89845fd72b0559c1c604281 Mon Sep 17 00:00:00 2001 From: mpenning Date: Sun, 8 Oct 2023 15:19:05 -0500 Subject: [PATCH 21/27] Update documentation --- dev_tools/deploy_docs/README.md | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/dev_tools/deploy_docs/README.md b/dev_tools/deploy_docs/README.md index ac7ec457..4740d4b0 100644 --- a/dev_tools/deploy_docs/README.md +++ b/dev_tools/deploy_docs/README.md @@ -1,22 +1,19 @@ # Overview -This is just a quick tool to upload my ccp markdown docs to my webserver with private key auth. +This is just a quick Go tool to upload my ccp markdown docs to my webserver with private key auth. + +It uses: +- [github melbahja/goph](https://github.com/melbahja/goph) for ssh automation +- [github gleich/logoru](https://github.com/gleich/logoru) for terminal logging To build this tool, `make build` and it will get all the required dependencies and compile them. -Run with `./deploy_docs` +Run with `make build` By default, you should see output like this... ```shell -$ ./deploy_docs -2023-06-23T09:13:24.844-0500 INFO deploy_docs/deploy_docs.go:16 Starting CiscoConfParse new documentation upload -2023-06-23T09:13:24.844-0500 INFO deploy_docs/deploy_docs.go:18 Initialize ssh key-auth -2023-06-23T09:13:24.844-0500 INFO deploy_docs/deploy_docs.go:25 ssh into remote webhost -2023-06-23T09:13:25.477-0500 INFO deploy_docs/deploy_docs.go:31 Remove old documentation files -2023-06-23T09:13:25.937-0500 INFO deploy_docs/deploy_docs.go:37 Start copying doc tarball to remote ssh server -2023-06-23T09:13:28.659-0500 INFO deploy_docs/deploy_docs.go:42 Finished copying tarball to remote ssh server -2023-06-23T09:13:28.659-0500 INFO deploy_docs/deploy_docs.go:44 extract CiscoConfParse documentation tarball -$ + + ``` From 89509d92ceb5479ecdd397a8b9a65643a8e4ea8f Mon Sep 17 00:00:00 2001 From: mpenning Date: Sun, 8 Oct 2023 15:19:36 -0500 Subject: [PATCH 22/27] Modifications incomplete... see github bug --- dev_tools/deploy_docs/src/deploy_docs.go | 81 +++++++++++++++++++++++- 1 file changed, 78 insertions(+), 3 deletions(-) diff --git a/dev_tools/deploy_docs/src/deploy_docs.go b/dev_tools/deploy_docs/src/deploy_docs.go index c152ff1b..1edd6a85 100644 --- a/dev_tools/deploy_docs/src/deploy_docs.go +++ b/dev_tools/deploy_docs/src/deploy_docs.go @@ -1,15 +1,90 @@ -package main +package deploy_docs import ( + // logoru is for colored logging... "github.com/gleich/logoru" + // golorama is for colored printing... + + // go-pretty is for colored text tables... + + // goph is for ssh automation... + "regexp" + "strconv" + "strings" + "time" + "github.com/melbahja/goph" ) +func localizedTime(timespec string, tzlocation string) string { + + // localize a Location to a standard timestring like + // 'UTC', 'Local', 'Pacific', or 'US/Chicago' + tzLoc, err := time.LoadLocation(tzlocation) + if err != nil { + logoru.Error(err.Error()) + } + + if strings.ToLower(timespec) == "now" { + timestamp := time.Now().In(tzLoc) + } else { + + // 2023-09-15 09:04:03 + dateRe := regexp.MustCompile(`^(?P\d{4})-(?P\d{2})-(?P\d{2})\s+(?P\d{2}):(?P\d{2}):(?P\d{2})$`) + dateRe_matches := dateRe.FindStringSubmatch(timespec) + // build the indexes into dateRe_matches... + yearIndex := dateRe.SubexpIndex("year") + monthIndex := dateRe.SubexpIndex("month") + dayIndex := dateRe.SubexpIndex("day") + hourIndex := dateRe.SubexpIndex("hour") + minuteIndex := dateRe.SubexpIndex("minute") + secondIndex := dateRe.SubexpIndex("second") + // build the integer values... + year, err := strconv.ParseInt(dateRe_matches[yearIndex], 10, 64) + if err != nil { + logoru.Critical(err.Error()) + } + month, err := strconv.ParseInt(dateRe_matches[monthIndex], 10, 64) + if err != nil { + logoru.Critical(err.Error()) + } + day, err := strconv.ParseInt(dateRe_matches[dayIndex], 10, 64) + if err != nil { + logoru.Critical(err.Error()) + } + hour, err := strconv.ParseInt(dateRe_matches[hourIndex], 10, 64) + if err != nil { + logoru.Critical(err.Error()) + } + minute, err := strconv.ParseInt(dateRe_matches[minuteIndex], 10, 64) + if err != nil { + logoru.Critical(err.Error()) + } + second, err := strconv.ParseInt(dateRe_matches[secondIndex], 10, 64) + if err != nil { + logoru.Critical(err.Error()) + } + + // timestamp from the timespec string... + timestamp := time.Date(year, month, day, hour, minute, second).In(tzLoc) + } + + return timestamp + +} + func main() { - logoru.Info("Starting Documentation build") + logoru.Info("Starting CiscoConfParse new documentation build and upload") - logoru.Info("Starting CiscoConfParse new documentation upload") + tzLoc_UTC, err := time.LoadLocation("UTC") + if err != nil { + logoru.Critical(err.Error()) + } + tzLoc_Local, _ := time.LoadLocation("Local") + if err != nil { + logoru.Critical(err.Error()) + } logoru.Info(" Initialize ssh key-auth") // Start new ssh connection with private key. From fa92f2d9ffddbec60e664dcf97e7b9d14940f68e Mon Sep 17 00:00:00 2001 From: mpenning Date: Sun, 8 Oct 2023 15:20:15 -0500 Subject: [PATCH 23/27] Remove accidental file commit --- dev_tools/deploy_docs/go.sum | 60 ------------------------------------ 1 file changed, 60 deletions(-) delete mode 100644 dev_tools/deploy_docs/go.sum diff --git a/dev_tools/deploy_docs/go.sum b/dev_tools/deploy_docs/go.sum deleted file mode 100644 index 02e16e2a..00000000 --- a/dev_tools/deploy_docs/go.sum +++ /dev/null @@ -1,60 +0,0 @@ -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/melbahja/goph v1.3.1 h1:FxFevAwCCpLkM4WBmnVVxcJBcBz6lKQpsN5biV2hA6w= -github.com/melbahja/goph v1.3.1/go.mod h1:uG+VfK2Dlhk+O32zFrRlc3kYKTlV6+BtvPWd/kK7U68= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.13.5 h1:a3RLUqkyjYRtBTZJZ1VRrKbN3zhuPLlUc3sphVz81go= -github.com/pkg/sftp v1.13.5/go.mod h1:wHDZ0IZX6JcBYRK1TH9bcVq8G7TLpVHYIGJRFnmPfxg= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= -github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 940fa75135a599a979749827bee0014cb8110448 Mon Sep 17 00:00:00 2001 From: mpenning Date: Tue, 10 Oct 2023 05:14:21 -0500 Subject: [PATCH 24/27] Disable better_exceptions --- ciscoconfparse/ccp_abc.py | 9 +++++---- ciscoconfparse/ccp_util.py | 9 +++++---- ciscoconfparse/ciscoconfparse.py | 9 +++++---- ciscoconfparse/errors.py | 9 +++++---- ciscoconfparse/models_asa.py | 9 +++++---- ciscoconfparse/models_cisco.py | 9 +++++---- ciscoconfparse/models_iosxr.py | 9 +++++---- ciscoconfparse/models_junos.py | 9 +++++---- ciscoconfparse/models_nxos.py | 9 +++++---- ciscoconfparse/protocol_values.py | 9 +++++---- 10 files changed, 50 insertions(+), 40 deletions(-) diff --git a/ciscoconfparse/ccp_abc.py b/ciscoconfparse/ccp_abc.py index d9a63a53..e16a9c00 100644 --- a/ciscoconfparse/ccp_abc.py +++ b/ciscoconfparse/ccp_abc.py @@ -24,10 +24,11 @@ import inspect import re -import better_exceptions -better_exceptions.MAX_LENGTH = None -better_exceptions.SUPPORTS_COLOR = True -better_exceptions.hook() +if False: + import better_exceptions + better_exceptions.MAX_LENGTH = None + better_exceptions.SUPPORTS_COLOR = True + better_exceptions.hook() from ciscoconfparse.ccp_util import junos_unsupported from loguru import logger diff --git a/ciscoconfparse/ccp_util.py b/ciscoconfparse/ccp_util.py index a5dfed69..a848c9ea 100644 --- a/ciscoconfparse/ccp_util.py +++ b/ciscoconfparse/ccp_util.py @@ -35,10 +35,11 @@ from ipaddress import collapse_addresses as ipaddr_collapse_addresses from ipaddress import AddressValueError -import better_exceptions -better_exceptions.MAX_LENGTH = None -better_exceptions.SUPPORTS_COLOR = True -better_exceptions.hook() +if False: + import better_exceptions + better_exceptions.MAX_LENGTH = None + better_exceptions.SUPPORTS_COLOR = True + better_exceptions.hook() from dns.exception import DNSException from dns.resolver import Resolver diff --git a/ciscoconfparse/ciscoconfparse.py b/ciscoconfparse/ciscoconfparse.py index 4531c41e..92634f6f 100644 --- a/ciscoconfparse/ciscoconfparse.py +++ b/ciscoconfparse/ciscoconfparse.py @@ -41,10 +41,11 @@ import re import os -import better_exceptions -better_exceptions.MAX_LENGTH = None -better_exceptions.SUPPORTS_COLOR = True -better_exceptions.hook() +if False: + import better_exceptions + better_exceptions.MAX_LENGTH = None + better_exceptions.SUPPORTS_COLOR = True + better_exceptions.hook() from ciscoconfparse.models_cisco import IOSHostnameLine, IOSRouteLine from ciscoconfparse.models_cisco import IOSIntfLine diff --git a/ciscoconfparse/errors.py b/ciscoconfparse/errors.py index 65882f61..93e3fb2f 100644 --- a/ciscoconfparse/errors.py +++ b/ciscoconfparse/errors.py @@ -22,10 +22,11 @@ mike [~at~] pennington [/dot\] net """ -import better_exceptions -better_exceptions.MAX_LENGTH = None -better_exceptions.SUPPORTS_COLOR = True -better_exceptions.hook() +if False: + import better_exceptions + better_exceptions.MAX_LENGTH = None + better_exceptions.SUPPORTS_COLOR = True + better_exceptions.hook() class BaseError(Exception): def __init__(self, msg=""): diff --git a/ciscoconfparse/models_asa.py b/ciscoconfparse/models_asa.py index efae8d47..fc52974c 100644 --- a/ciscoconfparse/models_asa.py +++ b/ciscoconfparse/models_asa.py @@ -32,10 +32,11 @@ import re -import better_exceptions -better_exceptions.MAX_LENGTH = None -better_exceptions.SUPPORTS_COLOR = True -better_exceptions.hook() +if False: + import better_exceptions + better_exceptions.MAX_LENGTH = None + better_exceptions.SUPPORTS_COLOR = True + better_exceptions.hook() from ciscoconfparse.protocol_values import ( ASA_TCP_PORTS, diff --git a/ciscoconfparse/models_cisco.py b/ciscoconfparse/models_cisco.py index abc74f19..4d44acb6 100644 --- a/ciscoconfparse/models_cisco.py +++ b/ciscoconfparse/models_cisco.py @@ -2,10 +2,11 @@ import traceback import re -import better_exceptions -better_exceptions.MAX_LENGTH = None -better_exceptions.SUPPORTS_COLOR = True -better_exceptions.hook() +if False: + import better_exceptions + better_exceptions.MAX_LENGTH = None + better_exceptions.SUPPORTS_COLOR = True + better_exceptions.hook() from ciscoconfparse.errors import DynamicAddressException diff --git a/ciscoconfparse/models_iosxr.py b/ciscoconfparse/models_iosxr.py index 0fd4d0d0..2a3afb1b 100644 --- a/ciscoconfparse/models_iosxr.py +++ b/ciscoconfparse/models_iosxr.py @@ -27,10 +27,11 @@ import re import os -import better_exceptions -better_exceptions.MAX_LENGTH = None -better_exceptions.SUPPORTS_COLOR = True -better_exceptions.hook() +if False: + import better_exceptions + better_exceptions.MAX_LENGTH = None + better_exceptions.SUPPORTS_COLOR = True + better_exceptions.hook() from ciscoconfparse.errors import DynamicAddressException diff --git a/ciscoconfparse/models_junos.py b/ciscoconfparse/models_junos.py index 6c1bea00..0059e6c1 100644 --- a/ciscoconfparse/models_junos.py +++ b/ciscoconfparse/models_junos.py @@ -31,10 +31,11 @@ import re -import better_exceptions -better_exceptions.MAX_LENGTH = None -better_exceptions.SUPPORTS_COLOR = True -better_exceptions.hook() +if False: + import better_exceptions + better_exceptions.MAX_LENGTH = None + better_exceptions.SUPPORTS_COLOR = True + better_exceptions.hook() from ciscoconfparse.ccp_abc import BaseCfgLine from ciscoconfparse.ccp_util import IPv4Obj diff --git a/ciscoconfparse/models_nxos.py b/ciscoconfparse/models_nxos.py index dc8eb065..c5586d02 100644 --- a/ciscoconfparse/models_nxos.py +++ b/ciscoconfparse/models_nxos.py @@ -32,10 +32,11 @@ import re -import better_exceptions -better_exceptions.MAX_LENGTH = None -better_exceptions.SUPPORTS_COLOR = True -better_exceptions.hook() +if False: + import better_exceptions + better_exceptions.MAX_LENGTH = None + better_exceptions.SUPPORTS_COLOR = True + better_exceptions.hook() from ciscoconfparse.errors import DynamicAddressException diff --git a/ciscoconfparse/protocol_values.py b/ciscoconfparse/protocol_values.py index e265595d..73ba8e80 100644 --- a/ciscoconfparse/protocol_values.py +++ b/ciscoconfparse/protocol_values.py @@ -1,9 +1,10 @@ from __future__ import absolute_import -import better_exceptions -better_exceptions.MAX_LENGTH = None -better_exceptions.SUPPORTS_COLOR = True -better_exceptions.hook() +if False: + import better_exceptions + better_exceptions.MAX_LENGTH = None + better_exceptions.SUPPORTS_COLOR = True + better_exceptions.hook() r""" protocol_values.py - Parse, Query, Build, and Modify IOS-style configurations From 83ca40f21b2e53fdb6ecf1469c01d5abf8222ae6 Mon Sep 17 00:00:00 2001 From: mpenning Date: Tue, 10 Oct 2023 05:16:16 -0500 Subject: [PATCH 25/27] Add another CHANGES item --- CHANGES.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index aa456805..fb87e84f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,13 @@ - Summary: - Insert something here +## Version: 1.8.0 + +- Released: 2023-10-09 +- Summary: + - Rewrite 'dev_tools/deploy_docs.py' as 'dev_tools/deploy_docs' in go + - Disable better_exceptions + ## Version: 1.7.25 - Released: 2023-07-10 From 0862dc8343fae9aa6e99bb7f14974415973f1aac Mon Sep 17 00:00:00 2001 From: mpenning Date: Tue, 10 Oct 2023 05:16:44 -0500 Subject: [PATCH 26/27] Add platform-specific builds --- dev_tools/deploy_docs/Makefile | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/dev_tools/deploy_docs/Makefile b/dev_tools/deploy_docs/Makefile index f5865fa2..69099ab5 100644 --- a/dev_tools/deploy_docs/Makefile +++ b/dev_tools/deploy_docs/Makefile @@ -13,6 +13,9 @@ GOOS=linux # Good primer on Makefile variables... # https://earthly.dev/blog/makefile-variables/ GO_SOURCE_FILE=src/deploy_docs.go +GO_BINARY_FILE=deploy_docs +# Find the platform (Linux or Darwin) from 'uname -a'... +PLATFORM := $(shell perl -e '`uname -a` =~ /^(\w+).*?$$/;print("$$1");') .DEFAULT_GOAL := build @@ -32,7 +35,22 @@ build: make dep -make lint cd src && go vet . - go build -o bin/deploy_docs -ldflags="-s -w" $(GO_SOURCE_FILE) + + ############################################################################ + # + # Replace this line with PLATFORM detection... + # + #go build -o bin/deploy_docs -ldflags="-s -w" $(GO_SOURCE_FILE) + # + ############################################################################ + if [ "$(PLATFORM)" = "Linux" ]; then \ + GOARCH=amd64 GOOS=linux go build -ldflags "-s -w" -o ./$(GO_BINARY_FILE) $(GO_SOURCE_FILE); \ + elif [ "$(PLATFORM)" = "Darwin" ]; then \ + GOARCH=amd64 GOOS=darwin go build -ldflags "-s -w" -o ./$(GO_BINARY_FILE) $(GO_SOURCE_FILE); \ + else \ + echo "$(COL_RED)Unknown PLATFORM -> $(PLATFORM)$(COL_END)"; \ + fi + make release .PHONY: build deploy: From da07e58678d3c22a1bdae5fef6e0060a2d4c1915 Mon Sep 17 00:00:00 2001 From: mpenning Date: Tue, 10 Oct 2023 05:18:25 -0500 Subject: [PATCH 27/27] Add go.sum --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index d4af811b..ac6eb6cc 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ build tags .tox .undodir + +go.sum