summaryrefslogtreecommitdiff
path: root/framework/backends
diff options
context:
space:
mode:
authorDylan Baker <baker.dylan.c@gmail.com>2016-01-05 14:48:10 -0800
committerDylan Baker <baker.dylan.c@gmail.com>2016-02-08 12:29:33 -0800
commitc9ae4f051e1d6d53d5a55b9b390ed668962c9aee (patch)
tree2566a0106df4af1b8f1b0aad4dec69ce19a86021 /framework/backends
parent86b933a4f8c58a60ee9c542d1db39550a643a016 (diff)
python: use six unicode/bytes/str handling
This is not feature complete for python 3.x in and of itself, but it gets started by using six functions rather than str and unicode. Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com> Acked-by: Jose Fonseca <jfonseca@vmware.com>
Diffstat (limited to 'framework/backends')
-rw-r--r--framework/backends/compression.py8
-rw-r--r--framework/backends/junit.py2
2 files changed, 6 insertions, 4 deletions
diff --git a/framework/backends/compression.py b/framework/backends/compression.py
index ab85a17ff..420c06815 100644
--- a/framework/backends/compression.py
+++ b/framework/backends/compression.py
@@ -27,8 +27,8 @@ DECOMPRESSORS, which use compression modes ('bz2', 'gz', 'xz', 'none') to
provide open-like functions with correct mode settings for writing or reading,
respectively.
-They should always take unicode objects. It is up to the caller to ensure that
-they're passing unicode and not bytes.
+They should always take unicode (str in python 3.x) objects. It is up to the
+caller to ensure that they're passing unicode and not bytes.
A helper, get_mode(), is provided to return the user selected mode (it will try
the PIGLIT_COMPRESSION environment variable, then the piglit.conf
@@ -46,6 +46,7 @@ import os
import subprocess
import contextlib
+import six
from six.moves import cStringIO as StringIO
from framework import exceptions
@@ -59,13 +60,14 @@ __all__ = [
]
+@six.python_2_unicode_compatible
class UnsupportedCompressor(exceptions.PiglitInternalError):
def __init__(self, method, *args, **kwargs):
super(UnsupportedCompressor, self).__init__(*args, **kwargs)
self.__method = method
def __str__(self):
- return 'unsupported compression method {}'.format(self.__method)
+ return u'unsupported compression method {}'.format(self.__method)
# TODO: in python3 the bz2 module has an open function
diff --git a/framework/backends/junit.py b/framework/backends/junit.py
index e6c5d3a72..cf48b40ae 100644
--- a/framework/backends/junit.py
+++ b/framework/backends/junit.py
@@ -104,7 +104,7 @@ class JUnitBackend(FileBackend):
continue
# set the test count by counting the number of tests.
- # This must be bytes or unicode
+ # This must be unicode (py3 str)
piglit.attrib['tests'] = str(len(piglit))
with open(os.path.join(self._dest, 'results.xml'), 'w') as f: