From afc520a3098d325b87a6575e49138c6bbf91da37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Palancher?= Date: Thu, 25 Nov 2021 10:54:17 +0100 Subject: [PATCH] Convert mcs_label from bytes to string if defined When it is defined, the mcs_label on nodes are bytes: # python3 Python 3.6.8 (default, Dec 5 2019, 15:45:45) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pyslurm >>> pyslurm.node().get()['cn1']['mcs_label'] b'label' >>> type(pyslurm.node().get()['cn1']['mcs_label']) With this commit, it is converted to a unicode string for easier handling by consumer. --- pyslurm/pyslurm.pyx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pyslurm/pyslurm.pyx b/pyslurm/pyslurm.pyx index a9584103..36606edc 100644 --- a/pyslurm/pyslurm.pyx +++ b/pyslurm/pyslurm.pyx @@ -3122,11 +3122,7 @@ cdef class node: slurm.stringOrNone(record.gres_used, '') ) - if record.mcs_label == NULL: - Host_dict[u'mcs_label'] = None - else: - Host_dict[u'mcs_label'] = record.mcs_label - + Host_dict[u'mcs_label'] = slurm.stringOrNone(record.mcs_label, '') Host_dict[u'mem_spec_limit'] = record.mem_spec_limit Host_dict[u'name'] = slurm.stringOrNone(record.name, '')