def METHOD_NAME(cmd, shell=True):
    try:
        proc = subprocess.Popen(cmd, shell=shell, stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT)
        while 1:
            output = proc.stdout.readline().rstrip()
            if output:
                print(output.decode('utf-8', 'backslashreplace'))
            if proc.poll() is not None:
                if proc.returncode != 0:  # must be called *after* poll()
                    print(f"Error executing command '{cmd}'")
                    return 1
                output = proc.stdout.readline().rstrip()
                if output:
                    print(output.decode('utf-8', 'backslashreplace'))
                break
    except (subprocess.CalledProcessError, OSError) as err:
        print(f"Error executing command '{cmd}'\n{err}")
        return 1
    return 0