Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue occurs when using arg "-p" in python code #189

Open
markict opened this issue Nov 16, 2022 · 1 comment
Open

issue occurs when using arg "-p" in python code #189

markict opened this issue Nov 16, 2022 · 1 comment
Assignees

Comments

@markict
Copy link

markict commented Nov 16, 2022

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/[email protected]/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/[email protected]/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/[email protected]/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
@sjpatel21
Copy link
Contributor

You can achieve something similar like this:
https://pubhub.devnetcloud.com/media/pyats/docs/topology/example.html#example-testbed-file
with the custom parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants