From fe618e3b0f22861abbe61aab2ac2e804662c6723 Mon Sep 17 00:00:00 2001 From: Ramon Figueiredo Pessoa Date: Wed, 17 Jan 2024 13:11:02 -0800 Subject: [PATCH 1/5] [rqd] Fix non ASCII chars Convert to ASCII while discarding characters that can not be encoded --- rqd/rqd/rqcore.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rqd/rqd/rqcore.py b/rqd/rqd/rqcore.py index 842028732..70bb949d1 100644 --- a/rqd/rqd/rqcore.py +++ b/rqd/rqd/rqcore.py @@ -1219,6 +1219,8 @@ def print_and_flush_ln(fd, last_timestamp): remainder = lines[-1] for line in lines[0:-1]: + # Convert to ASCII while discarding characters that can not be encoded + line = line.encode('ascii', 'ignore') print("[%s] %s" % (curr_line_timestamp, line), file=outfile) outfile.flush() os.fsync(outfile) From 8fdfc93c8630aca02c69ffdb4d2b45ae81e5daa5 Mon Sep 17 00:00:00 2001 From: Ramon Figueiredo Pessoa Date: Wed, 17 Jan 2024 15:47:59 -0800 Subject: [PATCH 2/5] [rqd] Fix non ASCII chars - Convert to ASCII while discarding characters that can not be encoded - Update sphinx version to 5.0.0 on docs/requirements.txt --- docs/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 9d324374d..1f3307af5 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,2 @@ -sphinx==4.3.1 +sphinx==5.0.0 sphinx-rtd-theme==1.0.0 From 20d5864b07ef2d0f2aa1b76eca083f8abe9c8cf4 Mon Sep 17 00:00:00 2001 From: Ramon Figueiredo Pessoa Date: Wed, 17 Jan 2024 15:54:32 -0800 Subject: [PATCH 3/5] [rqd] Fix non ASCII chars - Convert to ASCII while discarding characters that can not be encoded - Update sphinx version to 5.0.0 on docs/requirements.txt - Change docs/conf.py to use language = 'en' --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 2c8322352..230855ca1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -67,7 +67,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = 'en' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. From 31e14024a0d1d1ee3b45adfe029c005c5f2ad06c Mon Sep 17 00:00:00 2001 From: Ramon Figueiredo Pessoa Date: Fri, 19 Jan 2024 10:28:24 -0800 Subject: [PATCH 4/5] [rqd] Fix non ASCII chars Removing changes to update Sphinx version --- docs/conf.py | 2 +- docs/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 230855ca1..2c8322352 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -67,7 +67,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = 'en' +language = None # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. diff --git a/docs/requirements.txt b/docs/requirements.txt index 1f3307af5..9d324374d 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,2 @@ -sphinx==5.0.0 +sphinx==4.3.1 sphinx-rtd-theme==1.0.0 From 75f9236c7178efe30c82bdd6911eb2126c7afe1e Mon Sep 17 00:00:00 2001 From: Ramon Figueiredo Date: Wed, 3 Jul 2024 16:26:10 -0700 Subject: [PATCH 5/5] [rqd] Fix: Ensure consistent handling of non-ASCII characters in logs - Always encode lines to ASCII with 'ignore' option to discard non-ASCII characters. - Removed unused file_descriptor block and ensured consistent encoding logic. This change prevents UnicodeEncodeError and ensures consistent log outputs. --- rqd/rqd/rqcore.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/rqd/rqd/rqcore.py b/rqd/rqd/rqcore.py index 8184cdfe7..271ac6122 100644 --- a/rqd/rqd/rqcore.py +++ b/rqd/rqd/rqcore.py @@ -318,17 +318,13 @@ def runLinux(self): else: tempCommand += [self._createCommandFile(runFrame.command)] - if rqd.rqconstants.RQD_PREPEND_TIMESTAMP: - file_descriptor = subprocess.PIPE - else: - file_descriptor = self.rqlog # pylint: disable=subprocess-popen-preexec-fn frameInfo.forkedCommand = subprocess.Popen(tempCommand, env=self.frameEnv, cwd=self.rqCore.machine.getTempPath(), stdin=subprocess.PIPE, - stdout=file_descriptor, - stderr=file_descriptor, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, close_fds=True, preexec_fn=os.setsid) finally: @@ -343,6 +339,16 @@ def runLinux(self): if rqd.rqconstants.RQD_PREPEND_TIMESTAMP: pipe_to_file(frameInfo.forkedCommand.stdout, frameInfo.forkedCommand.stderr, self.rqlog) + else: + with open(self.rqlog, 'a') as f: + # Convert to ASCII while discarding characters that can not be encoded + for line in frameInfo.forkedCommand.stdout: + line = line.encode('ascii', 'ignore') + f.write(line.decode('ascii') + '\n') + for line in frameInfo.forkedCommand.stderr: + line = line.encode('ascii', 'ignore') + f.write(line.decode('ascii') + '\n') + returncode = frameInfo.forkedCommand.wait() # Find exitStatus and exitSignal