when I use Connection from unicon, and the args list contains -p the issue will occur.
we can reproduce this issue by the following code and cmd:
python3.10 hello.py -p ~/Downloads/magpies.rar
hello.py
from unicon import Connection
login_info = {
# the login info items
}
if __name__ == "__main__":
# let's suppose the arg "-p" is for other lines (not for pyats)
# xxxx
con = Connection(**login_info)
seems pyats treats the arg -p as its config file, however, intercepting the args should not be our expectation, yes?
error msg
Traceback (most recent call last):
File "/Users/XXX/Lab/python_test/hello.py", line 1, in <module>
from unicon import Connection
File "/opt/homebrew/lib/python3.10/site-packages/unicon/__init__.py", line 14, in <module>
from unicon.bases.connection import Connection
File "src/unicon/bases/connection.py", line 26, in init unicon.bases.connection
File "src/unicon/bases/routers/services.py", line 15, in init unicon.bases.routers.services
File "src/unicon/eal/dialogs.py", line 26, in init unicon.eal.dialogs
File "src/unicon/eal/dialog_processor.py", line 37, in init unicon.eal.dialog_processor
File "src/unicon/utils.py", line 9, in init unicon.utils
File "src/pyats/utils/secret_strings.py", line 29, in init pyats.utils.secret_strings
File "src/pyats/configuration.py", line 17, in init pyats.configuration
File "src/pyats/utils/import_utils/misc.py", line 16, in pyats.utils.import_utils.misc.on_import
File "src/pyats/configuration.py", line 35, in pyats.configuration._install
File "src/pyats/datastructures/configuration.py", line 38, in pyats.datastructures.configuration.Configuration.load_cfgs
File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/configparser.py", line 698, in read
self._read(fp, filename)
File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/configparser.py", line 1021, in _read
for lineno, line in enumerate(fp, start=1):
File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe7 in position 8: invalid continuation byte
when I use
Connection
fromunicon
, and the args list contains-p
the issue will occur.we can reproduce this issue by the following code and cmd:
python3.10 hello.py -p ~/Downloads/magpies.rar
hello.py
seems pyats treats the arg
-p
as its config file, however, intercepting the args should not be our expectation, yes?error msg