]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
misc.py: saner write_file() and sudo_write_file()
authorNathan Cutler <ncutler@suse.com>
Fri, 2 Mar 2018 13:55:37 +0000 (14:55 +0100)
committerKyr Shatskyy <kyrylo.shatskyy@suse.com>
Fri, 26 Apr 2019 07:06:21 +0000 (09:06 +0200)
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 <ncutler@suse.com>
teuthology/misc.py

index 2969ab9974b260e7d668e4c5111fb70bebc819b9..c52c14342a2beda0468336eee6ef825e439c66ea 100644 (file)
@@ -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,
     )