From 3bb5a246a7ff458eeb0d71d5fae1350b5a352109 Mon Sep 17 00:00:00 2001 From: Jeff Ohrstrom Date: Fri, 23 Aug 2024 10:01:47 -0400 Subject: [PATCH] force utf-8 encoding to avoid non-ASCII character errors (#118) --- lib/slurm_squeue_client.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/slurm_squeue_client.rb b/lib/slurm_squeue_client.rb index 1b2e6fc..a902236 100644 --- a/lib/slurm_squeue_client.rb +++ b/lib/slurm_squeue_client.rb @@ -173,11 +173,11 @@ def gpu_jobs_pending end def cluster_info - sinfo_out = sinfo.split('/') + sinfo_out = sinfo.to_s.force_encoding('UTF-8').split('/') running_jobs = 0 pending_jobs = 0 - squeue_jobs_running.split("\n").each{ |line| running_jobs += 1 } - squeue_jobs_pending.split("\n").each{ |line| pending_jobs += 1 } + squeue_jobs_running.to_s.force_encoding('UTF-8').split("\n").each{ |line| running_jobs += 1 } + squeue_jobs_pending.to_s.force_encoding('UTF-8').split("\n").each{ |line| pending_jobs += 1 } sinfo_out.each{ |line| # Strip extra chars returned by Slurm @@ -210,6 +210,8 @@ def setup rescue => e # TODO Add logging and a flash message that was removed from the controller # SlurmSqueueClientNotAvailable.new(cluster_id, cluster_title, e) + warn("error occured #{e}:#{e.message}") + warn(e.backtrace.join("\n")) end # Return the active jobs as percent of available jobs