[gnome-continuous-yocto/gnomeostree-3.28-rocko: 1193/8267] lib/oe/path: remove oe.path.check_output



commit e34eb01c0f0cf5e893d919eb74111115f57870f7
Author: Ross Burton <ross burton intel com>
Date:   Fri Jul 1 16:58:39 2016 +0100

    lib/oe/path: remove oe.path.check_output
    
    This was a copy-and-paste of subprocess.check_output() from when we supported
    Python <2.7, so simply delete it and use subprocess.check_output() instead.
    
    (From OE-Core rev: b1f2d9ed8d4dc89c9e669f43f546463ccc2a76b9)
    
    Signed-off-by: Ross Burton <ross burton intel com>
    Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>

 meta/lib/oe/path.py |   49 ++++---------------------------------------------
 1 files changed, 4 insertions(+), 45 deletions(-)
---
diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py
index 413ebfb..dbba60a 100644
--- a/meta/lib/oe/path.py
+++ b/meta/lib/oe/path.py
@@ -66,21 +66,21 @@ def copytree(src, dst):
 
     bb.utils.mkdirhier(dst)
     cmd = 'tar -cf - -C %s -p . | tar -xf - -C %s' % (src, dst)
-    check_output(cmd, shell=True, stderr=subprocess.STDOUT)
+    subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
 
 def copyhardlinktree(src, dst):
     """ Make the hard link when possible, otherwise copy. """
     bb.utils.mkdirhier(dst)
     if os.path.isdir(src) and not len(os.listdir(src)):
-        return 
+        return
 
     if (os.stat(src).st_dev ==  os.stat(dst).st_dev):
         # Need to copy directories only with tar first since cp will error if two 
         # writers try and create a directory at the same time
         cmd = 'cd %s; find . -type d -print | tar -cf - -C %s -p --files-from - --no-recursion | tar -xf - 
-C %s' % (src, src, dst)
-        check_output(cmd, shell=True, stderr=subprocess.STDOUT)
+        subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
         cmd = 'cd %s; find . -print0 | cpio --null -pdlu %s' % (src, dst)
-        check_output(cmd, shell=True, stderr=subprocess.STDOUT)
+        subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
     else:
         copytree(src, dst)
 
@@ -105,47 +105,6 @@ def symlink(source, destination, force=False):
         if e.errno != errno.EEXIST or os.readlink(destination) != source:
             raise
 
-class CalledProcessError(Exception):
-    def __init__(self, retcode, cmd, output = None):
-        self.retcode = retcode
-        self.cmd = cmd
-        self.output = output
-    def __str__(self):
-        return "Command '%s' returned non-zero exit status %d with output %s" % (self.cmd, self.retcode, 
self.output)
-
-# Not needed when we move to python 2.7
-def check_output(*popenargs, **kwargs):
-    r"""Run command with arguments and return its output as a byte string.
-
-    If the exit code was non-zero it raises a CalledProcessError.  The
-    CalledProcessError object will have the return code in the returncode
-    attribute and output in the output attribute.
-
-    The arguments are the same as for the Popen constructor.  Example:
-
-    >>> check_output(["ls", "-l", "/dev/null"])
-    'crw-rw-rw- 1 root root 1, 3 Oct 18  2007 /dev/null\n'
-
-    The stdout argument is not allowed as it is used internally.
-    To capture standard error in the result, use stderr=STDOUT.
-
-    >>> check_output(["/bin/sh", "-c",
-    ...               "ls -l non_existent_file ; exit 0"],
-    ...              stderr=STDOUT)
-    'ls: non_existent_file: No such file or directory\n'
-    """
-    if 'stdout' in kwargs:
-        raise ValueError('stdout argument not allowed, it will be overridden.')
-    process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
-    output, unused_err = process.communicate()
-    retcode = process.poll()
-    if retcode:
-        cmd = kwargs.get("args")
-        if cmd is None:
-            cmd = popenargs[0]
-        raise CalledProcessError(retcode, cmd, output=output)
-    return output
-
 def find(dir, **walkoptions):
     """ Given a directory, recurses into that directory,
     returning all files as absolute paths. """


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]