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

Removing the escape sequence from the console output! #139

Closed

Conversation

Anushree-Mathur
Copy link
Contributor

The output coming from the console Terminal consists of Bracketed Paste escape sequence! I have updated the code in a way that it will check the status output and see if the output has this sequence, it will remove this from the output and then use only integer o/p of status command!

Before applying the patch status output was:
^[[?2004l0

After applying the patch status output is:
0
Signed-off-by: Anushree Mathur [email protected]

The output coming from the console Terminal consists of Bracketed Paste escape sequence!
I have updated the code in a way that it will check the status output and see if the
output has this sequence, it will remove this from the output and then use only integer o/p of status command!

Before applying the patch status output was:
^[[?2004l0

After applying the patch status output is:
0

Signed-off-by: Anushree Mathur <[email protected]>
@Anushree-Mathur
Copy link
Contributor Author

Debug log for the run:
2045 [stdlog] revision : 2.0 (pvr 0080 0200)
2046 [stdlog]
2047 [stdlog] timebase : 512000000
2048 [stdlog] platform : pSeries
2049 [stdlog] model : IBM pSeries (emulated by qemu)
2050 [stdlog] machine : CHRP IBM pSeries (emulated by qemu)
2051 [stdlog] MMU : Radix
2052 [stdlog] ^[[?2004h[root@localhost ~]# echo $?
2053 [stdlog] ^[[?2004l0
2054 [stdlog] ^[[?2004h[root@localhost ~]#
2055 [stdlog] 2024-11-18 07:19:20,468 avocado.virttest.virsh virsh L1651 DEBUG| Define VM from /var/tmp/avocado_x1g4tgel/tmpi3v0aazb
2056 [stdlog] 2024-11-18 07:19:20,506 avocado.test stacktrace L0041 ERROR|
2057 [stdlog] 2024-11-18 07:19:20,506 avocado.test stacktrace L0043 ERROR| Reproduced traceback from: /usr/local/lib/python3.13/site-packages/avocado_vt/test.py:298
2058 [stdlog] 2024-11-18 07:19:20,507 avocado.test stacktrace L0050 ERROR| Traceback (most recent call last):
2059 [stdlog] 2024-11-18 07:19:20,507 avocado.test stacktrace L0050 ERROR| File "/home/Anu/tests/data/avocado-vt/virttest/test-providers.d/downloads/io-github-autotest-libvirt/l ibvirt/tests/src/virsh_cmd/domain/virsh_create.py", line 142, in run
2060 [stdlog] 2024-11-18 07:19:20,507 avocado.test stacktrace L0050 ERROR| test.fail("Fail to verify console")
2061 [stdlog] 2024-11-18 07:19:20,507 avocado.test stacktrace L0050 ERROR| ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
2062 [stdlog] 2024-11-18 07:19:20,507 avocado.test stacktrace L0050 ERROR| File "/usr/local/lib/python3.13/site-packages/avocado/core/test.py", line 754, in wrapper
2063 [stdlog] 2024-11-18 07:19:20,507 avocado.test stacktrace L0050 ERROR| return func(actual_message)
2064 [stdlog] 2024-11-18 07:19:20,508 avocado.test stacktrace L0050 ERROR| File "/usr/local/lib/python3.13/site-packages/avocado/core/test.py", line 770, in fail
2065 [stdlog] 2024-11-18 07:19:20,508 avocado.test stacktrace L0050 ERROR| raise exceptions.TestFail(msg)
2066 [stdlog] 2024-11-18 07:19:20,508 avocado.test stacktrace L0050 ERROR| avocado.core.exceptions.TestFail: Fail to verify console

Before applying the patch:

(04/13) type_specific.io-github-autotest-libvirt.virsh.create.console: STARTED
(04/13) type_specific.io-github-autotest-libvirt.virsh.create.console: FAIL: Fail to verify console (31.39 s)
(05/13) type_specific.io-github-autotest-libvirt.virsh.create.console_autodestroy: STARTED
(05/13) type_specific.io-github-autotest-libvirt.virsh.create.console_autodestroy: FAIL: Fail to verify console (36.26 s)
(06/13) type_specific.io-github-autotest-libvirt.virsh.create.console_paused: STARTED
(06/13) type_specific.io-github-autotest-libvirt.virsh.create.console_paused: FAIL: Fail to verify console (32.15 s)
(07/13) type_specific.io-github-autotest-libvirt.virsh.create.console_autodestroy_paused: STARTED
(07/13) type_specific.io-github-autotest-libvirt.virsh.create.console_autodestroy_paused: FAIL: Fail to verify console (37.00 s)

After applying the patch:

(04/13) type_specific.io-github-autotest-libvirt.virsh.create.console: STARTED
(04/13) type_specific.io-github-autotest-libvirt.virsh.create.console: PASS (31.62 s)
(05/13) type_specific.io-github-autotest-libvirt.virsh.create.console_autodestroy: STARTED
(05/13) type_specific.io-github-autotest-libvirt.virsh.create.console_autodestroy: PASS (35.64 s)
(06/13) type_specific.io-github-autotest-libvirt.virsh.create.console_paused: STARTED
(06/13) type_specific.io-github-autotest-libvirt.virsh.create.console_paused: PASS (31.00 s)
(07/13) type_specific.io-github-autotest-libvirt.virsh.create.console_autodestroy_paused: STARTED
(07/13) type_specific.io-github-autotest-libvirt.virsh.create.console_autodestroy_paused: PASS (34.93 s)

@PraveenPenguin
Copy link

@clebergnu can you please help to review this PR and merge

escape_sequence = r'\x1b\[\?[0-9;]*[hl]'

# Remove the Bracketed Paste Mode escape sequence using re.sub
clean_status = re.sub(escape_sequence, '', status)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it'd be more consistent to rely on aexpect.utils.astring.strip_console_codes. But apart from that it makes sense to strip extra characters that might be present...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the review @ldoktor! I will use this function and try once.

@Anushree-Mathur Anushree-Mathur closed this by deleting the head repository Nov 28, 2024
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.

3 participants