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

src/molecule/console.py: Don't always set output wrapping #2993

Closed
wants to merge 1 commit into from

Conversation

apatard
Copy link
Contributor

@apatard apatard commented Nov 23, 2020

The output soft wrapping with python enrich is enabled for all
terminals. This means that lines are wrapped to 80 when molecule
is run from tox or when a module ends importing this console module.
In the later case, this will wrap its output to 80 columns and
possibly break it, since the output won't be valid JSON as found in
ansible-community/molecule-vagrant#84.

As a possible solution, enable the soft wrapping on the same condition
as for the force_terminal terminal.

Signed-off-by: Arnaud Patard apatard@hupstream.com

PR Type

  • Bugfix Pull Request

The output soft wrapping with python enrich is enabled for all
terminals. This means that lines are wrapped to 80 when molecule
is run from tox or when a module ends importing this console module.
In the later case, this will wrap its output to 80 columns and
possibly break it, since the output won't be valid JSON as found in
ansible-community/molecule-vagrant#84.

As a possible solution, enable the soft wrapping on the same condition
as for the force_terminal terminal.

Signed-off-by: Arnaud Patard <apatard@hupstream.com>
Copy link
Member

@ssbarnea ssbarnea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the option name confused you because soft_wrap=True means do not wrap. soft_wrap=False means wrap at terminal width, default behavior on rich.

Default behavior of enrich.console.Console is to soft_wrap=True (not wrapping). Is one of the reasons I created enrich.

If is not working like this maybe there is a bug we need to fix, but we should not need to ever manually set soft_wrap=False.

@apatard
Copy link
Contributor Author

apatard commented Nov 23, 2020

ok, so a bug in enrich ?
fwiw, it's easy to reproduce it with: https://gist.github.com/apatard/d8ba985b9f48ba908057a726549dbbc2
It's producing:

python3 ./myexec.py 
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111

This leads to tox output looking like:

ANSIBLE_CALLBACK_WHITELIST=profile_tasks,timer ANSIBLE_COLLECTIONS_PATH=/home/va
grant/.cache/molecule/test-init/test-scenario/collections:/home/vagrant/.ansible
/collections:/usr/share/ansible/collections:/etc/ansible/collections
ANSIBLE_CONFIG=/home/vagrant/.cache/molecule/test-init/test-scenario/ansible.cfg

and also breaks molecule-vagrant

@apatard
Copy link
Contributor Author

apatard commented Nov 24, 2020

Fixed with enrich 1.2.3, so this PR is useless. I'm closing it.

@apatard apatard closed this Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-ansible that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-bootstrap that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-python that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-buildah that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-ceph_common that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-bamboo that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-bitbucket that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-catatonit that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-ceph_mon that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-ceph_osd that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-ceph_rgw that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-containerd that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-containernetworking_plugins that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-ceph_mds that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-ceph_mgr that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-cri_o that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-crun that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-conmon that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-crowd that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-etcd that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-cri_tools that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-cvs that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-flatpak that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-kube_kubelet that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-kernel that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-kube_master that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-kube_node that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-kube_kubeadm that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-kube_kubectl that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-libvirt that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-locales that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-node that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-packer that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-postfix that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-perforce that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-php that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-podman that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-postgres that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-restic that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-skopeo that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-mariadb that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-sqlite that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-runc that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-rclone that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-openjdk that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-sshd that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-vim that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-svn that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-timezone that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-mercurial that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-swap that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-vagrant that referenced this pull request Nov 24, 2020
hswong3i added a commit to alvistack/ansible-role-git that referenced this pull request Nov 24, 2020
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

Successfully merging this pull request may close these issues.

2 participants