From 29a95907c36cd3e791bdb281948324c719a50f77 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Sat, 10 Aug 2013 10:03:07 -0500 Subject: Revert "Probes: Fix failing nosetests" This reverts commit 4f745cc2731f7035f02566ba8bc1a0e9ae1b1a71. This breaks handling of unicode on python 2. --- src/lib/Bcfg2/Server/Plugins/Probes.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/lib/Bcfg2/Server/Plugins/Probes.py') diff --git a/src/lib/Bcfg2/Server/Plugins/Probes.py b/src/lib/Bcfg2/Server/Plugins/Probes.py index b9f93052a..35ae9d479 100644 --- a/src/lib/Bcfg2/Server/Plugins/Probes.py +++ b/src/lib/Bcfg2/Server/Plugins/Probes.py @@ -64,7 +64,7 @@ class ProbeData(str): # pylint: disable=E0012,R0924 .json, and .yaml properties to provide convenient ways to use ProbeData objects as XML, JSON, or YAML data """ def __new__(cls, data): - return str.__new__(cls, data) + return str.__new__(cls, data.encode('utf-8')) def __init__(self, data): # pylint: disable=W0613 str.__init__(self) @@ -225,9 +225,15 @@ class Probes(Bcfg2.Server.Plugin.Probing, lxml.etree.SubElement(top, 'Client', name=client, timestamp=str(int(probedata.timestamp))) for probe in sorted(probedata): - lxml.etree.SubElement( - ctag, 'Probe', name=probe, - value=self.probedata[client][probe]) + try: + lxml.etree.SubElement( + ctag, 'Probe', name=probe, + value=str( + self.probedata[client][probe]).decode('utf-8')) + except AttributeError: + lxml.etree.SubElement( + ctag, 'Probe', name=probe, + value=str(self.probedata[client][probe])) for group in sorted(self.cgroups[client]): lxml.etree.SubElement(ctag, "Group", name=group) try: -- cgit v1.2.3-1-g7c22 From 3b6b21c41101f1bb8be5cae096953b3907a38838 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Sat, 10 Aug 2013 10:04:03 -0500 Subject: Probes: Fix unicode probe handling Signed-off-by: Sol Jerome --- src/lib/Bcfg2/Server/Plugins/Probes.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/lib/Bcfg2/Server/Plugins/Probes.py') diff --git a/src/lib/Bcfg2/Server/Plugins/Probes.py b/src/lib/Bcfg2/Server/Plugins/Probes.py index 35ae9d479..ad25de194 100644 --- a/src/lib/Bcfg2/Server/Plugins/Probes.py +++ b/src/lib/Bcfg2/Server/Plugins/Probes.py @@ -9,6 +9,7 @@ import operator import lxml.etree import Bcfg2.Server import Bcfg2.Server.Plugin +from Bcfg2.Compat import unicode try: from django.db import models @@ -64,7 +65,10 @@ class ProbeData(str): # pylint: disable=E0012,R0924 .json, and .yaml properties to provide convenient ways to use ProbeData objects as XML, JSON, or YAML data """ def __new__(cls, data): - return str.__new__(cls, data.encode('utf-8')) + if isinstance(data, unicode): + return str.__new__(cls, data.encode('utf-8')) + else: + return str.__new__(cls, data) def __init__(self, data): # pylint: disable=W0613 str.__init__(self) -- cgit v1.2.3-1-g7c22 From b425fdec5edc55ce44d6f7f0e9dad89df14e4814 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Sat, 10 Aug 2013 10:17:05 -0500 Subject: Probes: Disable builtin redefinition check Signed-off-by: Sol Jerome --- src/lib/Bcfg2/Server/Plugins/Probes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/Bcfg2/Server/Plugins/Probes.py') diff --git a/src/lib/Bcfg2/Server/Plugins/Probes.py b/src/lib/Bcfg2/Server/Plugins/Probes.py index ad25de194..fd6fd3bd1 100644 --- a/src/lib/Bcfg2/Server/Plugins/Probes.py +++ b/src/lib/Bcfg2/Server/Plugins/Probes.py @@ -9,7 +9,7 @@ import operator import lxml.etree import Bcfg2.Server import Bcfg2.Server.Plugin -from Bcfg2.Compat import unicode +from Bcfg2.Compat import unicode # pylint: disable=W0622 try: from django.db import models -- cgit v1.2.3-1-g7c22