提交 6108ba5a 编写于 作者: L Lukáš Doktor

avocado.core.test: Use utils to produce safe-path name

This function can be used in other parts of this project (eg. remote).
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 cfc06b8e
......@@ -30,6 +30,7 @@ from . import data_dir
from . import exceptions
from . import multiplexer
from . import sysinfo
from ..utils import astring
from ..utils import data_structures
from ..utils import genio
from ..utils import path as utils_path
......@@ -102,7 +103,7 @@ class Test(unittest.TestCase):
self.tagged_name = self.get_tagged_name(base_logdir)
# Replace '/' with '_' to avoid splitting name into multiple dirs
safe_tagged_name = self.tagged_name.replace(os.path.sep, '_')
safe_tagged_name = astring.string_to_safe_path(self.tagged_name)
self.logdir = utils_path.init_dir(base_logdir, safe_tagged_name)
genio.set_log_file_dir(self.logdir)
self.logfile = os.path.join(self.logdir, 'debug.log')
......
......@@ -25,6 +25,7 @@ string. Even with the dot notation, people may try to do things like
And not notice until their code starts failing.
"""
import os.path
import re
......@@ -192,3 +193,12 @@ def tabular_output(matrix, header=None):
:rtype: str
"""
return "\n".join(iter_tabular_output(matrix, header))
def string_to_safe_path(string):
"""
Convert string to a valid file/dir name.
:param string: String to be converted
:return: String which is safe to pass as a file/dir name (on recent fs)
"""
return string.replace(os.path.sep, '_')
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册