From: Nathan Cutler Date: Fri, 2 Mar 2018 13:55:37 +0000 (+0100) Subject: misc.py: saner write_file() and sudo_write_file() X-Git-Tag: 1.1.0~250^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bfa8732062f824ca700890c293cdda45ea060232;p=teuthology.git misc.py: saner write_file() and sudo_write_file() Using python to do this might have made sense in 2011, but it doesn't now. Our hand is forced here, because systems are no longer guaranteed to have an executable called "python". For background details on why this is happening, see https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3#.2Fusr.2Fbin.2Fpython Signed-off-by: Nathan Cutler --- diff --git a/teuthology/misc.py b/teuthology/misc.py index 2969ab997..c52c14342 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -531,9 +531,8 @@ def write_file(remote, path, data): """ remote.run( args=[ - 'python', - '-c', - 'import shutil, sys; shutil.copyfileobj(sys.stdin, file(sys.argv[1], "wb"))', + 'cat', + run.Raw('>'), path, ], stdin=data, @@ -561,10 +560,9 @@ def sudo_write_file(remote, path, data, perms=None, owner=None): remote.run( args=[ 'sudo', - 'python', + 'sh', '-c', - 'import shutil, sys; shutil.copyfileobj(sys.stdin, file(sys.argv[1], "wb"))', - path, + 'cat > ' + path, ] + owner_args + permargs, stdin=data, )