I had an error, that i think could be a bug. See the part of the traceback that catched my attention:
in _load_from_string_lines
for line in config_text.splitlines():
└ ['interface Ethernet1/0/2', 'shutdown']
AttributeError: 'list' object has no attribute 'splitlines'
The code is expecting object "config_text" to be a String and convert it to a list. But it seems that it was already converted to a List in a step before.
CiscoConfParse Version
0.7.33
What Operating System are you using?
Linux - Debian, Ubuntu, CentOS, RHEL or others
What Python version(s) have this problem?
Python 3.10
Show us how to reproduce the problem. Please tell us if the problem is specific to certain inputs or situations.
from ciscoconfparse2.ciscoconfparse2 import Diff
# Parse the original configuration
old_config = 'fullconfig.conf'
new_config = 'newconfig.conf'
diff = Diff(old_config=old_config, new_config=new_config)
Python tracebacks
2024-04-06 13:13:54.391 | ERROR | __main__:<module>:1 - An error has been caught in function '<module>', process 'MainProcess' (44632), thread 'MainThread' (140103149501312):
Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
File "/home/malvarez/.pyenv/versions/venv_napalm_vrp/lib/python3.10/site-packages/ciscoconfparse2/ciscoconfparse2.py", line 3716, in __init__
self.host.load_generated_config(new_config)
│ │ └ ['interface Ethernet1/0/2', 'shutdown']
│ └ <member 'host' of 'Diff' objects>
└ <ciscoconfparse2.ciscoconfparse2.Diff object at 0x7f6c4aecc100>
File "/home/malvarez/.pyenv/versions/venv_napalm_vrp/lib/python3.10/site-packages/hier_config/host.py", line 127, in load_generated_config
self._generated_config = self._load_config(config_text)
│ │ │ │ └ ['interface Ethernet1/0/2', 'shutdown']
│ │ │ └ <function Host._load_config at 0x7f6c4c069fc0>
│ │ └ Host(hostname=example_hostname)
│ └ None
└ Host(hostname=example_hostname)
File "/home/malvarez/.pyenv/versions/venv_napalm_vrp/lib/python3.10/site-packages/hier_config/host.py", line 164, in _load_config
hier.load_from_string(config_text)
│ │ └ ['interface Ethernet1/0/2', 'shutdown']
│ └ <function HConfig.load_from_string at 0x7f6c4bfee680>
└ HConfig(host=Host(hostname=example_hostname))
File "/home/malvarez/.pyenv/versions/venv_napalm_vrp/lib/python3.10/site-packages/hier_config/root.py", line 140, in load_from_string
self._load_from_string_lines(config_text)
│ │ └ ['interface Ethernet1/0/2', 'shutdown']
│ └ <function HConfig._load_from_string_lines at 0x7f6c4bfeee60>
└ HConfig(host=Host(hostname=example_hostname))
File "/home/malvarez/.pyenv/versions/venv_napalm_vrp/lib/python3.10/site-packages/hier_config/root.py", line 337, in _load_from_string_lines
for line in config_text.splitlines():
└ ['interface Ethernet1/0/2', 'shutdown']
AttributeError: 'list' object has no attribute 'splitlines'
2024-04-06 13:13:54.391 | ERROR | __main__:<module>:1 - An error has been caught in function '<module>', process 'MainProcess' (44632), thread 'MainThread' (140103149501312):
Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
File "/home/malvarez/.pyenv/versions/venv_napalm_vrp/lib/python3.10/site-packages/ciscoconfparse2/ciscoconfparse2.py", line 3716, in __init__
self.host.load_generated_config(new_config)
│ │ └ ['interface Ethernet1/0/2', 'shutdown']
│ └ <member 'host' of 'Diff' objects>
└ <ciscoconfparse2.ciscoconfparse2.Diff object at 0x7f6c4aecc100>
File "/home/malvarez/.pyenv/versions/venv_napalm_vrp/lib/python3.10/site-packages/hier_config/host.py", line 127, in load_generated_config
self._generated_config = self._load_config(config_text)
│ │ │ │ └ ['interface Ethernet1/0/2', 'shutdown']
│ │ │ └ <function Host._load_config at 0x7f6c4c069fc0>
│ │ └ Host(hostname=example_hostname)
│ └ None
└ Host(hostname=example_hostname)
File "/home/malvarez/.pyenv/versions/venv_napalm_vrp/lib/python3.10/site-packages/hier_config/host.py", line 164, in _load_config
hier.load_from_string(config_text)
│ │ └ ['interface Ethernet1/0/2', 'shutdown']
│ └ <function HConfig.load_from_string at 0x7f6c4bfee680>
└ HConfig(host=Host(hostname=example_hostname))
File "/home/malvarez/.pyenv/versions/venv_napalm_vrp/lib/python3.10/site-packages/hier_config/root.py", line 140, in load_from_string
self._load_from_string_lines(config_text)
│ │ └ ['interface Ethernet1/0/2', 'shutdown']
│ └ <function HConfig._load_from_string_lines at 0x7f6c4bfeee60>
└ HConfig(host=Host(hostname=example_hostname))
File "/home/malvarez/.pyenv/versions/venv_napalm_vrp/lib/python3.10/site-packages/hier_config/root.py", line 337, in _load_from_string_lines
for line in config_text.splitlines():
└ ['interface Ethernet1/0/2', 'shutdown']
AttributeError: 'list' object has no attribute 'splitlines'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/malvarez/.pyenv/versions/venv_napalm_vrp/lib/python3.10/site-packages/loguru/_logger.py", line 1277, in catch_wrapper
return function(*args, **kwargs)
File "/home/malvarez/.pyenv/versions/venv_napalm_vrp/lib/python3.10/site-packages/ciscoconfparse2/ciscoconfparse2.py", line 3716, in __init__
self.host.load_generated_config(new_config)
File "/home/malvarez/.pyenv/versions/venv_napalm_vrp/lib/python3.10/site-packages/hier_config/host.py", line 127, in load_generated_config
self._generated_config = self._load_config(config_text)
File "/home/malvarez/.pyenv/versions/venv_napalm_vrp/lib/python3.10/site-packages/hier_config/host.py", line 164, in _load_config
hier.load_from_string(config_text)
File "/home/malvarez/.pyenv/versions/venv_napalm_vrp/lib/python3.10/site-packages/hier_config/root.py", line 140, in load_from_string
self._load_from_string_lines(config_text)
File "/home/malvarez/.pyenv/versions/venv_napalm_vrp/lib/python3.10/site-packages/hier_config/root.py", line 337, in _load_from_string_lines
for line in config_text.splitlines():
AttributeError: 'list' object has no attribute 'splitlines'
Contact Details
codingnetworks@gmail.com
What happened?
I tried to test the Diff Script that i found on the official documentation: http://www.pennington.net/py/ciscoconfparse2/tutorial_build_diffs.html#diff-script
for "old_config" i created the file "fullconfig.conf" with the following content:
For "new_config" i created the file "newconfig.conf" with the following content
When I got to this line.:
diff = Diff(old_config=old_config, new_config=new_config)
I had an error, that i think could be a bug. See the part of the traceback that catched my attention:
The code is expecting object "config_text" to be a String and convert it to a list. But it seems that it was already converted to a List in a step before.
CiscoConfParse Version
0.7.33
What Operating System are you using?
Linux - Debian, Ubuntu, CentOS, RHEL or others
What Python version(s) have this problem?
Python 3.10
Show us how to reproduce the problem. Please tell us if the problem is specific to certain inputs or situations.
Python tracebacks
Relevant log output
Code of Conduct