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

Unwanted characters printed after importing print_result #29

Open
geg347 opened this issue Jun 29, 2022 · 0 comments
Open

Unwanted characters printed after importing print_result #29

geg347 opened this issue Jun 29, 2022 · 0 comments

Comments

@geg347
Copy link

geg347 commented Jun 29, 2022

Hello,

With a colleague of mine we experienced an issue with print_result.

When we import the function in a script and use the standard print function, unwanted characters appear.

After debugging the cause, we found that the init function of colorama library is set in the print_result.py file but no deinit.

Bellow we highlighted the problem.

$ cat scripts/test1.py
#!/usr/bin/env python3

if __name__ == "__main__":
    print("hello, world")

$ poetry run scripts/test1.py | hexdump -C
00000000  68 65 6c 6c 6f 2c 20 77  6f 72 6c 64 0a           |hello, world.|
0000000d

# reproducing code
$ cat scripts/test2.py
#!/usr/bin/env python3

from nornir_utils.plugins.functions.print_result import print_result

if __name__ == "__main__":
    print("hello, world")

$ poetry run scripts/test2.py | hexdump -C
00000000  68 65 6c 6c 6f 2c 20 77  6f 72 6c 64 1b 5b 30 6d  |hello, world.[0m|
00000010  0a 1b 5b 30 6d                                    |..[0m|
00000015```

I will propose a fix in a PR.
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

1 participant