]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
task/internal: drop cStringIO for py3 compatibility 1329/head
authorKyr Shatskyy <kyrylo.shatskyy@suse.com>
Fri, 11 Oct 2019 19:35:36 +0000 (21:35 +0200)
committerKyr Shatskyy <kyrylo.shatskyy@suse.com>
Mon, 14 Oct 2019 16:30:26 +0000 (18:30 +0200)
Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@suse.com>
teuthology/task/internal/__init__.py

index cb095dee28a0bdf8cb8e252f209be122da9369e6..80832cbf6bd27634087e2ee3cc37b4e4f2f619a9 100644 (file)
@@ -3,7 +3,6 @@ Internal tasks are tasks that are started from the teuthology infrastructure.
 Note that there is no corresponding task defined for this module.  All of
 the calls are made from other modules, most notably teuthology/run.py
 """
-from cStringIO import StringIO
 import contextlib
 import logging
 import os
@@ -311,8 +310,7 @@ def fetch_binaries_for_coredumps(path, remote):
             dump_program = dump_out.split("from '")[1].split(' ')[0]
 
             # Find path on remote server:
-            r = remote.run(args=['which', dump_program], stdout=StringIO())
-            remote_path = r.stdout.getvalue()
+            remote_path = remote.sh(['which', dump_program]).rstrip()
 
             # Pull remote program into coredump folder:
             remote._sftp_get_file(remote_path, os.path.join(coredump_path,
@@ -443,20 +441,15 @@ def coredump(ctx, config):
         # set status = 'fail' if the dir is still there = coredumps were
         # seen
         for rem in ctx.cluster.remotes.keys():
-            r = rem.run(
-                args=[
-                    'if', 'test', '!', '-e', '{adir}/coredump'.format(adir=archive_dir), run.Raw(';'), 'then',
-                    'echo', 'OK', run.Raw(';'),
-                    'fi',
-                ],
-                stdout=StringIO(),
-            )
-            if r.stdout.getvalue() != 'OK\n':
-                log.warning('Found coredumps on %s, flagging run as failed', rem)
-                set_status(ctx.summary, 'fail')
-                if 'failure_reason' not in ctx.summary:
-                    ctx.summary['failure_reason'] = \
-                        'Found coredumps on {rem}'.format(rem=rem)
+            try:
+                rem.sh("test -e " + archive_dir + "/coredump")
+            except run.CommandFailedError:
+                continue
+            log.warning('Found coredumps on %s, flagging run as failed', rem)
+            set_status(ctx.summary, 'fail')
+            if 'failure_reason' not in ctx.summary:
+                ctx.summary['failure_reason'] = \
+                    'Found coredumps on {rem}'.format(rem=rem)
 
 
 @contextlib.contextmanager