Re: [Fuego] [fuego-core 1/7] ftc: docker ps will not work on the local board

<[email protected]> Thu, 22 Jul 2021 18:28:01 +0000
Newsgroups dev.linux.lists.fuego
Message-ID <BYAPR13MB2503D96B025F9CDBE0A95965FDE49@BYAPR13MB2503.namprd13.prod.outlook.com>
Looks good. Applied.

Thanks!
 -- Tim


> -----Original Message-----
> From: [email protected] <[email protected]>
> 
> From: Daniel Sangorrin <[email protected]>
> 
> When running fuego directly on the local board, instead of
> using a host-target approach, the check for a fuego
> container caused an error.
> 
> Signed-off-by: Daniel Sangorrin <[email protected]>
> Signed-off-by: venkata pyla <[email protected]>
> ---
>  scripts/ftc | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/scripts/ftc b/scripts/ftc
> index 4430dd2..2a6a640 100755
> --- a/scripts/ftc
> +++ b/scripts/ftc
> @@ -5153,11 +5153,15 @@ def get_running_fuego_container_name():
>          return cached_container_name
> 
>      # return the first container with "fuego" in the image or container name
> -    dps_lines = subprocess.check_output("sudo docker ps", shell=True).split('\n')
> -    for line in dps_lines:
> -        if "fuego" in line:
> -            cached_container_name = line.strip().split(" ")[-1]
> -            break
> +    try:
> +        with open(os.devnull, 'w') as devnull:
I was not familiar with this idiom for executing a subprocess with 2>/dev/null.
It's interesting...

> +            dps_lines = subprocess.check_output("sudo docker ps", shell=True, stderr=devnull).split('\n')
> +        for line in dps_lines:
> +            if "fuego" in line:
> +                cached_container_name = line.strip().split(" ")[-1]
> +                break
> +    except subprocess.CalledProcessError:
> +        return None
> 
>      return cached_container_name
> 
> --
> 2.20.1
>